public static Timer getNamedTotalTimer ( String timerName ) { long totalCpuTime = 0 ; long totalSystemTime = 0 ; int measurements = 0 ; int timerCount = 0 ; int todoFlags = RECORD_NONE ; Timer previousTimer = null ; for ( Map . Entry < Timer , Timer > entry : registeredTimers . entrySet ( ) ) { if ( entry . getValue ( ) . name . equals ( timerName ) ) { previousTimer = entry . getValue ( ) ; timerCount += 1 ; totalCpuTime += previousTimer . totalCpuTime ; totalSystemTime += previousTimer . totalWallTime ; measurements += previousTimer . measurements ; todoFlags |= previousTimer . todoFlags ; } } if ( timerCount == 1 ) { return previousTimer ; } else { Timer result = new Timer ( timerName , todoFlags , 0 ) ; result . totalCpuTime = totalCpuTime ; result . totalWallTime = totalSystemTime ; result . measurements = measurements ; result . threadCount = timerCount ; return result ; } }
Collect the total times measured by all known named timers of the given name . This is useful to add up times that were collected across separate threads .