public class TimeMetrics
extends java.lang.Object
Utility to collect temporal execution metrics of a repetitive task.
Copyright (C) 2007 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Field and Description |
---|---|
int |
count
Number of executions
|
private static java.lang.String |
cvsid |
boolean |
highRes
whether to count in us (default) or ns (high resolution)
|
int |
lastStartTime
Most recent execution start time in us (ns if
highRes ) |
int |
lastTime
Most recent execution time in us (ns if
highRes ) |
int |
maxTime
Maximum execution time in us (ns if
highRes ) |
int |
minTime
Minimum execution time in us (ns if
highRes ) or 0 if count 0 |
java.lang.String |
name
Name for these metrics
|
protected boolean |
running
whether a start has been marked without a matching end
|
long |
totalTime
Total execution time in us (ns if
highRes ) |
Constructor and Description |
---|
TimeMetrics(java.lang.String name)
Covers
TimeMetrics(String, boolean) , not high res. |
TimeMetrics(java.lang.String name,
boolean highRes)
calls
reset() |
Modifier and Type | Method and Description |
---|---|
float |
averageMS()
get
averageTime() in milliseconds |
int |
averageTime()
|
void |
dump(java.io.PrintStream s)
Covers
dump(PrintStream, int, boolean) , always annotated and 0
name width. |
void |
dump(java.io.PrintStream s,
int nameWidth)
covers
dump(PrintStream, int, boolean) , always annotated |
void |
dump(java.io.PrintStream s,
int nameWidth,
boolean annotated)
Dump human-readable metrics.
|
static void |
dumpHeader(java.io.PrintStream s,
int nameWidth,
boolean annotated)
dump a header line in fmt of
dump(PrintStream, int, boolean) |
int |
getCurrentTime()
get the current time in us (ns if
highRes ) |
boolean |
isRunning()
check if the start has been marked but not the end
|
float |
lastMS()
get
lastTime in milliseconds |
void |
markEnd()
Mark the end of a task execution.
|
void |
markStart()
Mark the start of a task execution.
|
void |
reset()
Resets all metrics
|
float |
toMS()
get multiplicative conversion factor taking time values to ms
|
private static final java.lang.String cvsid
public int minTime
highRes
) or 0 if count 0public int maxTime
highRes
)public long totalTime
highRes
)public int lastTime
highRes
)public int lastStartTime
highRes
)public int count
public final java.lang.String name
public final boolean highRes
protected boolean running
public TimeMetrics(java.lang.String name, boolean highRes)
reset()
public TimeMetrics(java.lang.String name)
Covers TimeMetrics(String, boolean)
, not high res.
public int averageTime()
public float averageMS()
averageTime()
in millisecondspublic float lastMS()
lastTime
in millisecondspublic float toMS()
public void reset()
public int getCurrentTime()
highRes
)public void markStart()
Mark the start of a task execution.
The task will be considered running (see isRunning()
) until the
next call to markEnd()
.
It is ok to call this even if the metrics are already running.
public void markEnd()
Mark the end of a task execution.
It is ok to call this even if the metrics are not currently running.
public boolean isRunning()
public void dump(java.io.PrintStream s, int nameWidth, boolean annotated)
Dump human-readable metrics.
nameWidth
- min width of the name
field, or non-positive for
no limitannotated
- whether to show per-number annotationspublic void dump(java.io.PrintStream s, int nameWidth)
dump(PrintStream, int, boolean)
, always annotatedpublic void dump(java.io.PrintStream s)
Covers dump(PrintStream, int, boolean)
, always annotated and 0
name width.
public static void dumpHeader(java.io.PrintStream s, int nameWidth, boolean annotated)
dump(PrintStream, int, boolean)