Accumulators and Events are commonly used to record data about the duration of an operation: the Event counts the number of times that an operation is performed, while the Accumulator records how long each operation takes to process. A Manager then uses this collected information to calculate the average time for the operation, as well as the standard deviation of all the times. To simplify the implementation for supporting this use case, the application may create and use Duration objects.
Each Duration is associated with a particular Accumulator, which in turn is associated with a single Event. Duration objects may be created at the top level of the Listener by calling the durationFactory method of the Listener object.
Duration elapsedTime = listener.durationFactory(accumulatorObject);
The accumulatorObject parameter is a reference to the Accumulator with which the Duration is associated. This object accumulates the recorded durations of the Event.
In FileNet® P8 4.0.0 and later, Duration Accumulators can be named using the DURATION constant of the Listener object. This constant provides a pre-defined String value of "duration", which is the only Accumulator name of any special significance to IBM® System Dashboard for Enterprise Content Management. DURATION is defined as public static final String “duration”. If you are working with an earlier release of IBM System Dashboard for Enterprise Content Management, your Duration Accumulators must be named with a hard-coded string value of "duration".
Once a Duration object has been created, it can be used to record Durations by calling the start method at the beginning of the period to be measured. Once the recording interval has completed, the stop method is called to calculate the time that has passed since start was executed. The elapsed time (nanoseconds) is recorded to the current Accumulator and returned.
When the application would like to increment the associated Event counter at the same time the Duration is recorded, the stop method may be called with a value of true.
Once stop has been called, a Duration object may be reused. If the next use case for the Duration object is for a different Accumulator, that Accumulator object may be specified as the argument to start when it is called. The different Accumulator then becomes the default for all accumulations, until another Accumulator is specified in a future call to start.