public class Stopwatch extends Object
This class is not thread-safe.
| Constructor and Description |
|---|
Stopwatch()
Creates a new stopwatch with default counter types
|
Stopwatch(Counter.Type... types)
Creates a new stopwatch with specific counter types
|
| Modifier and Type | Method and Description |
|---|---|
static Stopwatch |
createStarted()
Provides a started stopwatch for convenience with default counter types
|
static Stopwatch |
createStarted(Counter.Type... types)
Provides a started stopwatch for convenience with specific counter types
|
Collection<Counter> |
getAllCounters() |
Counter |
getCounter(Counter.Type type) |
void |
printStatistics(PrintStream printStream)
Prints stopwatch statistics in the specified print stream.
|
void |
printStatistics(PrintStream printStream,
TimeUnit timeUnit)
Prints stopwatch statistics in the specified print stream, with a custom time unit.
|
void |
reset()
Resets all counters for this stopwatch
|
void |
start()
Starts the stopwatch
|
void |
stop()
Stops the stopwatch
|
public Stopwatch()
public Stopwatch(Counter.Type... types)
types - the types to be setpublic static Stopwatch createStarted()
public static Stopwatch createStarted(Counter.Type... types)
types - the types to be setpublic void reset()
public void start()
public void stop()
public Collection<Counter> getAllCounters()
public Counter getCounter(Counter.Type type)
type - the counter type to be fetchedpublic void printStatistics(PrintStream printStream)
printStream - the print stream to which statistics will be sentpublic void printStatistics(PrintStream printStream, TimeUnit timeUnit)
printStream - the print stream to which statistics will be senttimeUnit - the time unit for the elapsed times to be displayedCopyright © 2019. All rights reserved.