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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
finish()
Finish benchmarking: calculates the results.long
getName()
The handler of the single benchmark operation to run.The operation to benchmark.get all properties added to the implementation.int
getRate()
boolean
setIterations(int iterations)
void
setOperation(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:
setIterations
in interfaceBenchmark
- Parameters:
iterations
- the number of iterations this benchmark will be executed for.- Returns:
- fluent
-
setName
-
setOperation
-
start
Description copied from interface:Benchmark
Start measuring of the execution time. -
finish
public void finish()Description copied from interface:Benchmark
Finish benchmarking: calculates the results. -
isFinished
public boolean isFinished()- Specified by:
isFinished
in interfaceBenchmark
- Returns:
- returns true if
Benchmark.finish()
has been called.
-
getElapsedMS
public long getElapsedMS()- Specified by:
getElapsedMS
in interfaceBenchmark
- Returns:
- the time taken to complete the benchmark in ms.
-
getOperation
Description copied from interface:Benchmark
The operation to benchmark.- Specified by:
getOperation
in interfaceBenchmark
- Returns:
- an executable benchmark.
-
getName
Description copied from interface:Benchmark
The handler of the single benchmark operation to run. Should typically match the method handler. -
setProperty
Description copied from interface:Benchmark
Sets a property on the benchmark object, may be a parameter or a result.- Specified by:
setProperty
in interfaceBenchmark
- Parameters:
key
- the key to identify this propertyvalue
- the value to insert- Returns:
- fluent
-
getProperties
Description copied from interface:Benchmark
get all properties added to the implementation.- Specified by:
getProperties
in interfaceBenchmark
- Returns:
- a map of all the properties that has been set.
-
getTimeFormatted
- Specified by:
getTimeFormatted
in interfaceBenchmarkResult
- Returns:
- time formatted as HH:mm:ss.SSS using the elapsed ms as source.
-
getRateFormatted
- Specified by:
getRateFormatted
in interfaceBenchmarkResult
- Returns:
- the number of operations per second as a formatted string.
-
getRate
public int getRate()- Specified by:
getRate
in interfaceBenchmarkResult
- Returns:
- the number of operations per second.
-