public class Timing extends Object
For example, when trying to figure out which
Service
would be the best candidate to speed up
Context
initialization, this helper comes in real handy:
it accumulates a list of operations with their duration and prints out a
sorted list when asked to.
Use this class as following:
private static Timing timing = new Timing(); ... private void oneOperation() { final long t1 = System.nanoTime(); ... timing.add(System.nanoTime() - t1, "Operation #1"); } ... private void atEnd() { ... timing.report("Operations"); }
Constructor and Description |
---|
Timing() |
Modifier and Type | Method and Description |
---|---|
void |
addTiming(long duration,
Object message) |
void |
addTiming(Object message) |
void |
report(String description) |
void |
reset() |
static Timing |
start(boolean condition) |
static void |
stop(Timing timing) |
static void |
tick(Timing timing) |
static void |
tick(Timing timing,
Object message) |
public void reset()
public void addTiming(Object message)
public void addTiming(long duration, Object message)
public void report(String description)
public static Timing start(boolean condition)
public static void tick(Timing timing)
public static void stop(Timing timing)
Copyright © 2015–2022 SciJava. All rights reserved.