public static void main ( String [ ] args ) { System . out . println ( "Wait for it... (~10s or more)" ) ; for ( int i = 0 ; i < ITERATIONS ; i ++ ) { try ( Split ignored = SimonManager . getStopwatch ( STOPWATCH_PARENT + Manager . HIERARCHY_DELIMITER + random . nextInt ( STOPWATCH_COUNT ) ) . start ( ) ) { ExampleUtils . waitRandomlySquared ( 20 ) ; } } // this is "unknown" Simon, but you don't care - just take all the children and do the stuff you want Simon parent = SimonManager . getSimon ( STOPWATCH_PARENT ) ; List < Simon > children = parent . getChildren ( ) ; System . out . println ( "parent.children count = " + children . size ( ) + ' ' ) ; // programmatic example - not counting parent itself, because here it is not used long totalSum = 0 ; for ( Simon child : children ) { System . out . println ( child ) ; // do whatever you need to do here... totalSum += ( ( Stopwatch ) child ) . getTotal ( ) ; } System . out . println ( "Programmatic totalSum = " + SimonUtils . presentNanoTime ( totalSum ) ) ; // using utils available @since 3.5 System . out . println ( "\nSimonUtils.calculateStopwatchAggregate(parent) = " + SimonUtils . calculateStopwatchAggregate ( parent ) ) ; }
Entry point to the Aggregation Example .