org.apache.jmeter.util

## Class Calculator

- java.lang.Object
- - org.apache.jmeter.util.Calculator

-     public class Calculator
      extends java.lang.Object

  Class to calculate various items that don't require all previous results to be saved:
  - mean = average
  - standard deviation
  - minimum
  - maximum

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Calculator()`
    `Calculator(java.lang.String label)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBytes(long newValue)` add received bytes
    `void` | `addSample(SampleResult res)` Add details for a sample result, which may consist of multiple samples.
    `void` | `clear()`
    `double` | `getAvgPageBytes()` calculates the average page size, which means divide the bytes by number of samples.
    `double` | `getBytesPerSecond()` Throughput in bytes / second
    `int` | `getCount()`
    `double` | `getErrorPercentage()` Returns the raw double value of the percentage of samples with errors that were recorded.
    `double` | `getKBPerSecond()` Sent Throughput in kilobytes / second
    `java.lang.String` | `getLabel()`
    `long` | `getMax()`
    `double` | `getMean()`
    `java.lang.Number` | `getMeanAsNumber()`
    `long` | `getMin()`
    `double` | `getRate()` Returns the throughput associated to this sampler in requests per second.
    `double` | `getSentBytesPerSecond()` Sent bytes / second
    `double` | `getSentKBPerSecond()` Sent bytes throughput in kilobytes / second
    `double` | `getStandardDeviation()`
    `long` | `getTotalBytes()`

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

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

- - ### Constructor Detail

    - #### Calculator

          public Calculator()

    - #### Calculator

          public Calculator(java.lang.String label)

  - ### Method Detail

    - #### clear

          public void clear()

    - #### addSample

          public void addSample(SampleResult res)

      Add details for a sample result, which may consist of multiple samples. Updates the number of bytes read and sent, error count, startTime and elapsedTime
      Parameters:
        `res` - the sample result; might represent multiple values

    - #### addBytes

          public void addBytes(long newValue)

      add received bytes
      Parameters:
        `newValue` - received bytes

    - #### getTotalBytes

          public long getTotalBytes()

    - #### getMean

          public double getMean()

    - #### getMeanAsNumber

          public java.lang.Number getMeanAsNumber()

    - #### getStandardDeviation

          public double getStandardDeviation()

    - #### getMin

          public long getMin()

    - #### getMax

          public long getMax()

    - #### getCount

          public int getCount()

    - #### getLabel

          public java.lang.String getLabel()

    - #### getErrorPercentage

          public double getErrorPercentage()

      Returns the raw double value of the percentage of samples with errors that were recorded. (Between 0.0 and 1.0)
      Returns:
        the raw double value of the percentage of samples with errors that were recorded.

    - #### getRate

          public double getRate()

      Returns the throughput associated to this sampler in requests per second. May be slightly skewed because it takes the timestamps of the first and last samples as the total time passed, and the test may actually have started before that start time and ended after that end time.
      Returns:
        throughput associated to this sampler in requests per second

    - #### getAvgPageBytes

          public double getAvgPageBytes()

      calculates the average page size, which means divide the bytes by number of samples.
      Returns:
        average page size in bytes

    - #### getBytesPerSecond

          public double getBytesPerSecond()

      Throughput in bytes / second
      Returns:
        throughput in bytes/second

    - #### getKBPerSecond

          public double getKBPerSecond()

      Sent Throughput in kilobytes / second
      Returns:
        Sent Throughput in kilobytes / second

    - #### getSentBytesPerSecond

          public double getSentBytesPerSecond()

      Sent bytes / second
      Returns:
        throughput in bytes/second

    - #### getSentKBPerSecond

          public double getSentKBPerSecond()

      Sent bytes throughput in kilobytes / second
      Returns:
        Throughput in kilobytes / second

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.