public class ElkTimer extends Object
| Modifier and Type | Field and Description |
|---|---|
protected long |
currentStartCpuTime |
protected long |
currentStartWallTime |
protected boolean |
isRunning |
protected int |
measurements |
protected String |
name |
static int |
RECORD_ALL
Flag for indicating that all supported times should be taken.
|
static int |
RECORD_CPUTIME
Flag for indicating that CPU time should be taken.
|
static int |
RECORD_NONE
Flag for indicating that no times should be taken (just count runs).
|
static int |
RECORD_WALLTIME
Flag for indicating that wall clock time should be taken.
|
protected int |
threadCount |
protected long |
threadId |
protected int |
todoFlags |
protected long |
totalCpuTime |
protected long |
totalWallTime |
| Constructor and Description |
|---|
ElkTimer(String name,
int todoFlags,
long threadId)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
long |
getAvgCpuTime() |
long |
getAvgWallTime() |
String |
getName()
Get the string name of the timer.
|
static ElkTimer |
getNamedTimer(String timerName)
Get a timer of the given string name that takes all possible times
(todos) for the current thread.
|
static ElkTimer |
getNamedTimer(String timerName,
int todoFlags)
Get a timer of the given string name and todos for the current thread.
|
static ElkTimer |
getNamedTimer(String timerName,
int todoFlags,
long threadId)
Get a timer of the given string name for the given thread.
|
static Iterable<ElkTimer> |
getNamedTimers()
Returns all registered timers
|
static ElkTimer |
getNamedTotalTimer(String timerName)
Collect the total times measured by all known named timers of the given
name.
|
protected static long |
getThreadCpuTime(long threadId) |
long |
getThreadId()
Get the ID of the thread for which this timer was created.
|
static ElkTimer |
getTimerForCurrentThread(String name,
int todoFlags) |
long |
getTotalCpuTime()
Get the total recorded CPU time in nanoseconds.
|
long |
getTotalWallTime()
Get the total recorded wall clock time in nanoseconds.
|
int |
hashCode() |
boolean |
isRunning()
Return true if the timer is running.
|
void |
log(org.apache.log4j.Logger logger)
Print logging information for the timer using debug priority.
|
void |
log(org.apache.log4j.Logger logger,
org.apache.log4j.Priority priority)
Print logging information for the timer.
|
static void |
logAllNamedTimers(String timerName,
org.apache.log4j.Logger logger) |
static void |
logAllNamedTimers(String timerName,
org.apache.log4j.Logger logger,
org.apache.log4j.Priority priority) |
void |
reset()
Stop the timer (if running) and reset all recorded values.
|
static void |
resetNamedTimer(String timerName)
Reset a timer of the given string name for all todos and the current
thread.
|
static void |
resetNamedTimer(String timerName,
int todoFlags)
Reset a timer of the given string name for the current thread.
|
static void |
resetNamedTimer(String timerName,
int todoFlags,
long threadId)
Reset a timer of the given string name for the given thread.
|
void |
start()
Start the timer.
|
static void |
startNamedTimer(String timerName)
Start a timer of the given string name for all todos and the current
thread.
|
static void |
startNamedTimer(String timerName,
int todoFlags)
Start a timer of the given string name for the current thread.
|
static void |
startNamedTimer(String timerName,
int todoFlags,
long threadId)
Start a timer of the given string name for the current thread.
|
long |
stop()
Stop the timer and return the CPU time that has passed since it had last
been started.
|
static long |
stopNamedTimer(String timerName)
Stop a timer of the given string name for all todos and the current
thread.
|
static long |
stopNamedTimer(String timerName,
int todoFlags)
Stop a timer of the given string name for the current thread.
|
static long |
stopNamedTimer(String timerName,
int todoFlags,
long threadId)
Stop a timer of the given string name for the given thread.
|
public static final int RECORD_NONE
public static final int RECORD_CPUTIME
public static final int RECORD_WALLTIME
public static final int RECORD_ALL
protected final String name
protected final long threadId
protected final int todoFlags
protected long currentStartCpuTime
protected long currentStartWallTime
protected boolean isRunning
protected long totalCpuTime
protected long totalWallTime
protected int measurements
protected int threadCount
public ElkTimer(String name, int todoFlags, long threadId)
name - todoFlags - threadId - public static ElkTimer getTimerForCurrentThread(String name, int todoFlags)
name - todoFlags - ElkTimer for the current threadpublic long getTotalCpuTime()
public long getAvgCpuTime()
public String getName()
public long getThreadId()
public long getTotalWallTime()
public long getAvgWallTime()
public boolean isRunning()
public void start()
public void reset()
public long stop()
public void log(org.apache.log4j.Logger logger)
logger - log()public void log(org.apache.log4j.Logger logger,
org.apache.log4j.Priority priority)
logger - priority - public static void startNamedTimer(String timerName)
timerName - the name of the timerpublic static void startNamedTimer(String timerName, int todoFlags)
timerName - the name of the timertodoFlags - public static void startNamedTimer(String timerName, int todoFlags, long threadId)
timerName - the name of the timertodoFlags - threadId - of the thread to track, or 0 if only system clock should be
trackedpublic static long stopNamedTimer(String timerName)
timerName - the name of the timerpublic static long stopNamedTimer(String timerName, int todoFlags)
timerName - the name of the timertodoFlags - public static long stopNamedTimer(String timerName, int todoFlags, long threadId)
timerName - the name of the timertodoFlags - threadId - of the thread to track, or 0 if only system clock should be
trackedpublic static void resetNamedTimer(String timerName)
timerName - the name of the timerpublic static void resetNamedTimer(String timerName, int todoFlags)
timerName - the name of the timertodoFlags - public static void resetNamedTimer(String timerName, int todoFlags, long threadId)
timerName - the name of the timertodoFlags - threadId - of the thread to track, or 0 if only system clock should be
trackedpublic static ElkTimer getNamedTimer(String timerName)
timerName - the name of the timerpublic static Iterable<ElkTimer> getNamedTimers()
public static ElkTimer getNamedTimer(String timerName, int todoFlags)
timerName - the name of the timertodoFlags - public static ElkTimer getNamedTimer(String timerName, int todoFlags, long threadId)
timerName - the name of the timertodoFlags - threadId - of the thread to track, or 0 if only system clock should be
trackedpublic static ElkTimer getNamedTotalTimer(String timerName)
timerName - public static void logAllNamedTimers(String timerName, org.apache.log4j.Logger logger)
public static void logAllNamedTimers(String timerName, org.apache.log4j.Logger logger, org.apache.log4j.Priority priority)
protected static long getThreadCpuTime(long threadId)
Copyright © 2011-2015 Department of Computer Science, University of Oxford. All Rights Reserved.