Package org.apache.jmeter.visualizers
Class RunningSample
java.lang.Object
org.apache.jmeter.visualizers.RunningSample
Running sample data container. Just instantiate a new instance of this
class, and then call addSample(SampleResult)
a few times, and pull
the stats out with whatever methods you prefer.
Please note that this class is not thread-safe. The calling class is responsible for ensuring thread safety if required. Versions prior to 2.3.2 appeared to be thread-safe but weren't as label and index were not final. Also the caller needs to synchronize access in order to ensure that variables are consistent.
-
Constructor Summary
ConstructorDescriptionRunningSample
(String label, int index) Use this constructor to create the initial instanceCopy constructor to create a duplicate of existing instance (without the disadvantages of clone() -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSample
(SampleResult res) Records a sample.void
Adds another RunningSample to this one.void
clear()
Clear the counters (useful for differential stats)long
Returns the average time in milliseconds that samples ran in.long
Get the elapsed time for the sampleslong
double
Returns the raw double value of the percentage of samples with errors that were recorded.Returns a String which represents the percentage of sample errors that have occurred.int
getIndex()
getLabel()
long
getMax()
Returns the time in milliseconds of the slowest sample.long
getMin()
Returns the time in milliseconds of the quickest sample.long
Returns the number of samples that have been recorded by this instance of the RunningSample class.double
getRate()
Returns the throughput associated to this sampler in requests per second.double
Returns the throughput associated to this sampler in requests per min.Returns a String that represents the throughput associated for this sampler, in units appropriate to its dimension:toString()
-
Constructor Details
-
RunningSample
Use this constructor to create the initial instance- Parameters:
label
- the label for this componentindex
- the index of this component
-
RunningSample
Copy constructor to create a duplicate of existing instance (without the disadvantages of clone()- Parameters:
src
- existing RunningSample to be copied
-
-
Method Details
-
clear
public void clear()Clear the counters (useful for differential stats) -
getElapsed
public long getElapsed()Get the elapsed time for the samples- Returns:
- how long the samples took
-
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 with this sampler per second
-
getRatePerMin
public double getRatePerMin()Returns the throughput associated to this sampler in requests per min. 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 with this sampler per minute
-
getRateString
Returns a String that represents the throughput associated for this sampler, in units appropriate to its dimension:The number is represented in requests/second or requests/minute or requests/hour.
Examples: "34.2/sec" "0.1/sec" "43.0/hour" "15.9/min"
- Returns:
- a String representation of the rate the samples are being taken at.
-
getLabel
- Returns:
- the label for this component
-
getIndex
public int getIndex()- Returns:
- the index of this component
-
addSample
Records a sample.- Parameters:
res
- sample to record
-
addSample
Adds another RunningSample to this one. Does not check if it has the same label and index.- Parameters:
rs
- sample to add
-
getMin
public long getMin()Returns the time in milliseconds of the quickest sample.- Returns:
- the time in milliseconds of the quickest sample.
-
getMax
public long getMax()Returns the time in milliseconds of the slowest sample.- Returns:
- the time in milliseconds of the slowest sample.
-
getAverage
public long getAverage()Returns the average time in milliseconds that samples ran in.- Returns:
- the average time in milliseconds that samples ran in.
-
getNumSamples
public long getNumSamples()Returns the number of samples that have been recorded by this instance of the RunningSample class.- Returns:
- the number of samples that have been recorded by this instance of the RunningSample class.
-
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) If you want a nicer return format, seegetErrorPercentageString()
.- Returns:
- the raw double value of the percentage of samples with errors that were recorded.
-
getErrorPercentageString
Returns a String which represents the percentage of sample errors that have occurred. ("0.00%" through "100.00%")- Returns:
- a String which represents the percentage of sample errors that have occurred.
-
toString
-
getErrorCount
public long getErrorCount()- Returns:
- errorCount
-