TransactionBenchmark

public abstract class TransactionBenchmark implements Serializable

The TransactionBenchmark object allows to store the time which some actions take. At its core, it consists of:

A list of named Measurements.A list of named SubBenchmarks.

Each measurement may be recorded on multiple occasions, the stored Measurement objects keep a statistic about the total and average recorded times.

Fields

isActive

protected static final transient boolean isActive

logger

public final transient Logger logger

measurements

protected final Map<String, Measurement> measurements

since

long since

stackTraceElements

protected StackTraceElement[] stackTraceElements

subBenchmarks

protected final Map<String, SubBenchmark> subBenchmarks

Constructors

TransactionBenchmark

protected TransactionBenchmark()

Methods

addMeasurement

public void addMeasurement(Object object, long time)

Add a measurement. The object will be toString()’ed. The string serves as a key.

Parameters:
  • object

  • time

addMeasurement

public void addMeasurement(Object object, long time, int count)

Add a measurement. The object will be toString()’ed. The string serves as a key.

Parameters:
  • object

  • time

  • count

addMeasurement

public void addMeasurement(Measurement measurement)

Add a measurement.

Parameters:
  • measurement

called_from

public String called_from()

Return a String (or null) denoting where this TransactionBenchmark was created from.

createBenchmark

public TransactionBenchmark createBenchmark(String name)

Create a new independent TransactionBenchmark. Existing benchmarks with the same name are overwritten by this method.

This is for starting a series of measurements from a clean slate.

However, the Measurements and Benchmarks are still recorded in the RootBenchmark too.

Parameters:
Returns:

a new TransactionBenchmark

createBenchmark

public TransactionBenchmark createBenchmark(Class<?> class1)

Create a sub-benchmark with the name of the given class, overwriting existing ones with the same name.

getBenchmark

public TransactionBenchmark getBenchmark(String name)

Return (and create if necessary) the sub-benchmark with the given name.

getBenchmark

public TransactionBenchmark getBenchmark(Class<?> class1)

Return (and create if necessary) the sub-benchmark with the name of the given class.

getMeasurements

public Iterable<Measurement> getMeasurements()

getName

public abstract String getName()

getRootInstance

public static TransactionBenchmark getRootInstance()

getSubBenchmarks

public Iterable<SubBenchmark> getSubBenchmarks()

toElement

public Element toElement()

toString

public String toString()