void sanityCheck ( ) throws IllegalStateException { if ( getStatus ( ) != TimeInstrumentStatus . STOPPED ) { throw new IllegalStateException ( "time instrument [" + getName ( ) + " is not stopped" ) ; } long totalElapsed = globalStopWatch . elapsedTime ( ) ; long childTotal = 0 ; for ( TimeInstrument ti : childTimeInstrumentList ) { childTotal += ti . elapsedTime ( ) ; if ( ti . getStatus ( ) != TimeInstrumentStatus . STOPPED ) { throw new IllegalStateException ( "time instrument [" + ti . getName ( ) + " is not stopped" ) ; } if ( ti instanceof Profiler ) { Profiler nestedProfiler = ( Profiler ) ti ; nestedProfiler . sanityCheck ( ) ; } } if ( totalElapsed < childTotal ) { throw new IllegalStateException ( "children have a higher accumulated elapsed time" ) ; } }
This method is used in tests .