org.perf4j.helpers
Class GroupingStatisticsIterator

java.lang.Object
  extended by org.perf4j.helpers.GroupingStatisticsIterator
All Implemented Interfaces:
Iterator<GroupedTimingStatistics>

public class GroupingStatisticsIterator
extends Object
implements Iterator<GroupedTimingStatistics>

This Iterator wraps a StopWatchLogIterator to return a single GroupedTimingStatistics object for each time slice detected. Thus, this iterator is a "gearing" iterator - if there are on average 100 StopWatches logged during each time slice, the underlying StopWatchLogIterator will return 100 StopWatches for each single GroupedTimingStatistics object returned by this Iterator.

Note that it's assumed that the StopWatch Iterator is ordered according to start time. If this is not true, then this class will create GroupedTimingStatistics that may reflect StopWatch data from a previous time slice.

Author:
Alex Devine

Constructor Summary
GroupingStatisticsIterator(Iterator<StopWatch> stopWatchIterator)
          Creates a GroupingStatisticsIterator that groups StopWatch instances pulled from the specified stopWatchIterator into GroupedTimingStatistics.
GroupingStatisticsIterator(Iterator<StopWatch> stopWatchIterator, long timeSlice, boolean createRollupStatistics)
          Creates a GroupingStatisticsIterator that groups StopWatch instances pulled from the specified stopWatchIterator into GroupedTimingStatistics.
 
Method Summary
 boolean hasNext()
           
 GroupedTimingStatistics next()
           
 void remove()
          Remove is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupingStatisticsIterator

public GroupingStatisticsIterator(Iterator<StopWatch> stopWatchIterator)
Creates a GroupingStatisticsIterator that groups StopWatch instances pulled from the specified stopWatchIterator into GroupedTimingStatistics. A timeslice of 30 seconds is used and rollup statistics are not created.

Parameters:
stopWatchIterator - The StopWatch Iterator that provides the StopWatch instances. If stopWatchIterator returns a null value, will check to see if a timeslice is over and return GroupedTimingStatistics if necessary.

GroupingStatisticsIterator

public GroupingStatisticsIterator(Iterator<StopWatch> stopWatchIterator,
                                  long timeSlice,
                                  boolean createRollupStatistics)
Creates a GroupingStatisticsIterator that groups StopWatch instances pulled from the specified stopWatchIterator into GroupedTimingStatistics.

Parameters:
stopWatchIterator - The StopWatch Iterator that provides the StopWatch instances. If stopWatchIterator returns a null value, will check to see if a timeslice is over and return GroupedTimingStatistics if necessary.
timeSlice - The length of each time slice, in milliseconds.
createRollupStatistics - Whether or not entries for "rollup" tags should be created
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<GroupedTimingStatistics>

next

public GroupedTimingStatistics next()
Specified by:
next in interface Iterator<GroupedTimingStatistics>

remove

public void remove()
Remove is not supported.

Specified by:
remove in interface Iterator<GroupedTimingStatistics>
Throws:
UnsupportedOperationException - Always thrown.


Copyright © 2008-2011 perf4j.org. All Rights Reserved.