IBM FileNet P8, Version 5.2            

Measuring Elapsed Time with Durations

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.

Tip: The Duration object does not necessarily need to be used in order to measure the elapsed time. If timing information is already available in an application, the application may simply record the time using the appropriate Accumulator.

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.

Naming

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".

Using start and stop

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.

Reusing a Duration Class

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.



Feedback

Last updated: October 2013
p8plj011.htm

© Copyright IBM Corporation 2014.
This information center is powered by Eclipse technology. (http://www.eclipse.org)