public class RunningSample
extends java.lang.Object
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 and Description |
---|
RunningSample(RunningSample src)
Copy constructor to create a duplicate of existing instance (without the
disadvantages of clone()
|
RunningSample(java.lang.String label,
int index)
Use this constructor to create the initial instance
|
Modifier and Type | Method and Description |
---|---|
void |
addSample(RunningSample rs)
Adds another RunningSample to this one.
|
void |
addSample(SampleResult res)
Records a sample.
|
void |
clear()
Clear the counters (useful for differential stats)
|
long |
getAverage()
Returns the average time in milliseconds that samples ran in.
|
long |
getElapsed()
Get the elapsed time for the samples
|
long |
getErrorCount() |
double |
getErrorPercentage()
Returns the raw double value of the percentage of samples with errors
that were recorded.
|
java.lang.String |
getErrorPercentageString()
Returns a String which represents the percentage of sample errors that
have occurred. ("0.00%" through "100.00%")
|
int |
getIndex() |
java.lang.String |
getLabel() |
long |
getMax()
Returns the time in milliseconds of the slowest sample.
|
long |
getMin()
Returns the time in milliseconds of the quickest sample.
|
long |
getNumSamples()
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 |
getRatePerMin()
Returns the throughput associated to this sampler in requests per min.
|
java.lang.String |
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.
|
java.lang.String |
toString()
For debugging purposes, mainly.
|
public RunningSample(java.lang.String label, int index)
label
- the label for this componentindex
- the index of this componentpublic RunningSample(RunningSample src)
src
- existing RunningSample to be copiedpublic void clear()
public long getElapsed()
public double getRate()
public double getRatePerMin()
public java.lang.String getRateString()
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"
public java.lang.String getLabel()
public int getIndex()
public void addSample(SampleResult res)
res
- sample to recordpublic void addSample(RunningSample rs)
rs
- sample to addpublic long getMin()
public long getMax()
public long getAverage()
public long getNumSamples()
public double getErrorPercentage()
getErrorPercentageString()
.public java.lang.String getErrorPercentageString()
public java.lang.String toString()
toString
in class java.lang.Object
public long getErrorCount()
Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.