|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.sparql.benchmarking.parallel.ParallelTimer
public class ParallelTimer
A Timer that can be used to time runtime where runtime may be being consumed on multiple threads and overlapping, allows you to determine actual runtime used.
Essentially this is just a class that tracks the number of threads that have
started the timer and the time at which the timer was last started when there
were no active threads using synchronized
to ensure that only one
thread can access a method at any one time.
Then when the timer is stopped and there are no active threads the total time elapsed can be incremented by the difference between the last start time and the current time. It may be the case that multiple distinct threads have run and started and stopped the timer. But provided active threads is greater than zero at least one thread is performing the operation we wish to time so we are always counting actual time and not counting time multiply as we would be doing if we just summed the individual runtimes of the threads.
Constructor Summary | |
---|---|
ParallelTimer()
|
Method Summary | |
---|---|
long |
getActiveThreads()
Gets the number of active threads currently consuming runtime in parallel |
long |
getActualRuntime()
Gets the actual runtime consumed |
void |
start()
Starts timing |
void |
stop()
Stops timing |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParallelTimer()
Method Detail |
---|
public void start()
public void stop()
public long getActualRuntime()
public long getActiveThreads()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |