|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmartin.common.Stopwatch
public class Stopwatch
Class useful for profiling the time usage of java software. Consecutive calls using the same label are added together to a total sum. Example: Stopwatch s = new Stopwatch("Method 1"); method1(); s.stop(); Stopwatch.printStatistics();
| Field Summary | |
|---|---|
private static java.util.Map<java.lang.String,java.lang.Integer> |
hits
|
private java.lang.String |
label
|
private long |
startTime
|
private static java.util.Map<java.lang.String,java.lang.Long> |
sums
|
private static java.util.concurrent.Semaphore |
totalSem
|
| Constructor Summary | |
|---|---|
Stopwatch(java.lang.String label)
Returns a running Stopwatch object. |
|
| Method Summary | |
|---|---|
void |
cancel()
Stops the stopwatch, without adding the elapsed time to the global data store. |
static void |
printStats()
|
void |
start()
Starts the stopwatch, storing the time when this function is called. |
static Stopwatch |
startNew(java.lang.String label)
Starts the stopwatch, storing the time when this function is called. |
long |
stop()
Stops the Stopwatch, and adds the elapsed time to a global sum for the label specified on construction. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.util.Map<java.lang.String,java.lang.Long> sums
private static java.util.Map<java.lang.String,java.lang.Integer> hits
private static java.util.concurrent.Semaphore totalSem
private long startTime
private java.lang.String label
| Constructor Detail |
|---|
public Stopwatch(java.lang.String label)
label - | Method Detail |
|---|
public static Stopwatch startNew(java.lang.String label)
public void start()
public void cancel()
public long stop()
public static void printStats()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||