Class BenchmarkBuilder
java.lang.Object
com.codingchili.core.benchmarking.BenchmarkBuilder
- All Implemented Interfaces:
Benchmark,BenchmarkResult
Base implementation of a benchmark.
-
Field Summary
Fields inherited from interface com.codingchili.core.benchmarking.BenchmarkResult
DATE_FORMAT, EPOCH_BASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()Finish benchmarking: calculates the results.longgetName()The handler of the single benchmark operation to run.The operation to benchmark.get all properties added to the implementation.intgetRate()booleansetIterations(int iterations)voidsetOperation(BenchmarkOperation operation)setProperty(String key, Object value)Sets a property on the benchmark object, may be a parameter or a result.start()Start measuring of the execution time.
-
Constructor Details
-
BenchmarkBuilder
Creates a new benchmark builder.- Parameters:
name- the name of the benchmark to build.
-
-
Method Details
-
setIterations
- Specified by:
setIterationsin interfaceBenchmark- Parameters:
iterations- the number of iterations this benchmark will be executed for.- Returns:
- fluent
-
setName
-
setOperation
-
start
Description copied from interface:BenchmarkStart measuring of the execution time. -
finish
public void finish()Description copied from interface:BenchmarkFinish benchmarking: calculates the results. -
isFinished
public boolean isFinished()- Specified by:
isFinishedin interfaceBenchmark- Returns:
- returns true if
Benchmark.finish()has been called.
-
getElapsedMS
public long getElapsedMS()- Specified by:
getElapsedMSin interfaceBenchmark- Returns:
- the time taken to complete the benchmark in ms.
-
getOperation
Description copied from interface:BenchmarkThe operation to benchmark.- Specified by:
getOperationin interfaceBenchmark- Returns:
- an executable benchmark.
-
getName
Description copied from interface:BenchmarkThe handler of the single benchmark operation to run. Should typically match the method handler. -
setProperty
Description copied from interface:BenchmarkSets a property on the benchmark object, may be a parameter or a result.- Specified by:
setPropertyin interfaceBenchmark- Parameters:
key- the key to identify this propertyvalue- the value to insert- Returns:
- fluent
-
getProperties
Description copied from interface:Benchmarkget all properties added to the implementation.- Specified by:
getPropertiesin interfaceBenchmark- Returns:
- a map of all the properties that has been set.
-
getTimeFormatted
- Specified by:
getTimeFormattedin interfaceBenchmarkResult- Returns:
- time formatted as HH:mm:ss.SSS using the elapsed ms as source.
-
getRateFormatted
- Specified by:
getRateFormattedin interfaceBenchmarkResult- Returns:
- the number of operations per second as a formatted string.
-
getRate
public int getRate()- Specified by:
getRatein interfaceBenchmarkResult- Returns:
- the number of operations per second.
-