org.javasimon.utils
Class BenchmarkUtils.Task
java.lang.Object
org.javasimon.utils.BenchmarkUtils.Task
- All Implemented Interfaces:
- Runnable
- Enclosing class:
- BenchmarkUtils
public abstract static class BenchmarkUtils.Task
- extends Object
- implements Runnable
Helper object that requires implementing the perform() method with benchmarked block of code.
Calling run() executes the code and measures statistics using the stopwatch named in the
constructor. Calling perform() executes the code without the stopwatch being used.
It is not recommended to implement too short Task repeated for many runs (thousands or millions)
but rather to impelement loop in the task to measure short operations and run the Task for units
of times (tens, hundreds). Otherwise Simon overhead (mostly System.nanoTime() call) may
distort the results. If the measured operation is extremely short even the for loop can distort the results.
|
Method Summary |
abstract void |
perform()
Performes the measured block of code without actual measuring. |
void |
run()
Executes perform() and measures the run using the Stopwatch named in the constructor. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stopwatchName
private String stopwatchName
BenchmarkUtils.Task
protected BenchmarkUtils.Task(String stopwatchName)
- Protected constructor intended for extension.
- Parameters:
stopwatchName - name of the stopwatch (measuring name)
run
public void run()
- Executes
perform() and measures the run using the Stopwatch named in the constructor.
- Specified by:
run in interface Runnable
perform
public abstract void perform()
throws Exception
- Performes the measured block of code without actual measuring.
- Throws:
Exception - any exception can be thrown here
Copyright © 2013. All Rights Reserved.