weka.gui.beans

## Class StreamThroughput

- java.lang.Object
- - weka.gui.beans.StreamThroughput

- All Implemented Interfaces:
    java.io.Serializable

      public class StreamThroughput
      extends java.lang.Object
      implements java.io.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:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StreamThroughput(java.lang.String statusMessagePrefix)` Construct a new StreamThroughput
    `StreamThroughput(java.lang.String statusMessagePrefix, java.lang.String initialMessage, Logger log)` Construct a new StreamThroughput

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `finished()` Register the end of measurement.
    `java.lang.String` | `finished(Logger log)` Register the end of measurement.
    `int` | `getAverageInstancesPerSecond()` Get the average instances per second
    `void` | `setSamplePeriod(int period)` Set the sampling period (in milliseconds) to compute througput over
    `void` | `updateEnd(Logger log)` Register a throughput measurement end point.
    `void` | `updateStart()` Register a throughput measurement start point

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StreamThroughput

          public StreamThroughput(java.lang.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(java.lang.String statusMessagePrefix,
                          java.lang.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 Detail

    - #### 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 java.lang.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 java.lang.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.