Class StreamThroughput

java.lang.Object
weka.gui.beans.StreamThroughput
All Implemented Interfaces:
Serializable

public class StreamThroughput extends Object implements Serializable
Class for measuring throughput of an incremental Knowledge Flow step. Typical usage is to construct a StreamThroughput object at the start of the stream (i.e. FORMAT_AVAILABLE event) and then for each instance received call updateStart() just before processing the instance and then updateEnd() just after. If updateEnd() is called *before* sending any event to downstream step(s) then throughput just with respect to work done by the step will be measured. Elapsed time to process each instance (along with the number of instances) is accumulated over the sample time period. Instances per second is computed at the end of each sample period and added to a running total. Average instances/sec is reported to the status area of the log.
Version:
$Revision: 9243 $
Author:
Mark Hall (mhall{[at]}pentaho{[dot]}com)
See Also:
  • Constructor Details

    • StreamThroughput

      public StreamThroughput(String statusMessagePrefix)
      Construct a new StreamThroughput
      Parameters:
      statusMessagePrefix - the unique identifier of the Knowledge Flow component being measured. This enables the correct line in the status area to be updated. See any Knowledge Flow step for an example.
    • StreamThroughput

      public StreamThroughput(String statusMessagePrefix, String initialMessage, Logger log)
      Construct a new StreamThroughput
      Parameters:
      statusMessagePrefix - the unique identifier of the Knowledge Flow component being measured. This enables the correct line in the status area to be updated. See any Knowledge Flow step for an example.
      initialMessage - an initial message to print to the status area for this step on construction
      log - the log to write status updates to
  • Method Details

    • setSamplePeriod

      public void setSamplePeriod(int period)
      Set the sampling period (in milliseconds) to compute througput over
      Parameters:
      period - the sampling period in milliseconds
    • updateStart

      public void updateStart()
      Register a throughput measurement start point
    • updateEnd

      public void updateEnd(Logger log)
      Register a throughput measurement end point. Collects counts and statistics. Will update the status area for the KF step in question if the sample period has elapsed.
      Parameters:
      log - the log to write status updates to
    • getAverageInstancesPerSecond

      public int getAverageInstancesPerSecond()
      Get the average instances per second
      Returns:
      the average instances per second processed
    • finished

      public String finished(Logger log)
      Register the end of measurement. Writes a "Finished" update (that includes the final throughput info) to the status area of the log.
      Parameters:
      log - the log to write to
      Returns:
      the message written to the status area.
    • finished

      public String finished()
      Register the end of measurement. Does not write a "Finished" update to the log
      Returns:
      a message that contains the final throughput info.