|
Web Site | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.janino.util.Benchmark
public class Benchmark
Implements a scheme for benchmarking, i.e. for determining and/or reporting the time elapsed between the beginning and the end of an activity.
The measurement is done by invoking begin()
and later calling end()
whichs
returns the time elapsed since the call to begin()
.
Notice that calls to begin()
and end()
can be nested, and each call to
end()
refers to the matching begin()
call. To ensure that all calls match,
the preferred way to write a benchmark is
... Benchmark b = new Benchmark(); ... b.begin(); try { .... } finally { long ms = b.end(); }This code layout also makes it visually easy to write correct pairs of
begin()
/
end()
pairs.
The pair beginReporting()
and endReporting()
do basically the same, but
report the benchmarking information through an internal Benchmark.Reporter
object. The default
Benchmark.Reporter
prints its messages by System.out.println()
.
Reporting is only enabled if the Benchmark object was created through Benchmark(boolean)
with a true
argument.
Nested Class Summary | |
---|---|
static interface |
Benchmark.Reporter
Interface used to report messages. |
Constructor Summary | |
---|---|
Benchmark()
|
|
Benchmark(boolean reportingEnabled)
Set up a Benchmark with a default Benchmark.Reporter that reports to
System.out . |
|
Benchmark(boolean reportingEnabled,
Benchmark.Reporter reporter)
Set up a Benchmark with a custom Benchmark.Reporter . |
Method Summary | |
---|---|
void |
begin()
|
void |
beginReporting()
Begin a benchmark (see begin() ) and report the fact. |
void |
beginReporting(java.lang.String message)
Begin a benchmark (see begin() ) and report the fact. |
long |
end()
|
void |
endReporting()
End a benchmark (see end() ) and report the fact. |
void |
endReporting(java.lang.String message)
End a benchmark (see begin() ) and report the fact. |
void |
report(java.lang.String message)
Report the given message. |
void |
report(java.lang.String optionalTitle,
java.lang.Object o)
Report the title , a colon, a space, and the pretty-printed
Object . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Benchmark()
public Benchmark(boolean reportingEnabled)
Benchmark
with a default Benchmark.Reporter
that reports to
System.out
.
public Benchmark(boolean reportingEnabled, Benchmark.Reporter reporter)
Benchmark
with a custom Benchmark.Reporter
.
Method Detail |
---|
public void begin()
Benchmark
public long end()
Benchmark
public void beginReporting()
begin()
) and report the fact.
public void beginReporting(java.lang.String message)
begin()
) and report the fact.
public void endReporting()
end()
) and report the fact.
public void endReporting(java.lang.String message)
begin()
) and report the fact.
public void report(java.lang.String message)
public void report(java.lang.String optionalTitle, java.lang.Object o)
title
, a colon, a space, and the pretty-printed
Object
.
optionalTitle
- o
-
|
Web Site | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |