| Constructor and Description |
|---|
StopWatch()
Constructor
|
StopWatch(Date theStart)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
endCurrentTask()
Finish the counter on the current task (which was started by calling
startTask(String). |
static String |
formatMillis(double theMillis)
Formats a number of milliseconds for display (e.g.
|
static String |
formatMillis(long theMillis)
Formats a number of milliseconds for display (e.g.
|
String |
formatMillisPerOperation(long theNumOperations)
Returns a nice human-readable display of the time taken per
operation.
|
String |
formatTaskDurations()
Returns a string providing the durations of all tasks collected by
startTask(String) |
String |
formatThroughput(long theNumOperations,
TimeUnit theUnit)
Determine the current throughput per unit of time (specified in theUnit)
assuming that theNumOperations operations have happened.
|
String |
getEstimatedTimeRemaining(double theCompleteToDate,
double theTotal)
Given an amount of something completed so far, and a total amount, calculates how long it will take for something to complete
|
long |
getMillis() |
long |
getMillis(Date theNow) |
long |
getMillisAndRestart() |
long |
getMillisPerOperation(long theNumOperations) |
Date |
getStartedDate() |
double |
getThroughput(long theNumOperations,
TimeUnit theUnit)
Determine the current throughput per unit of time (specified in theUnit)
assuming that theNumOperations operations have happened.
|
void |
restart() |
void |
startTask(String theTaskName)
Starts a counter for a sub-task
|
String |
toString()
Formats value in an appropriate format.
|
public StopWatch()
public void endCurrentTask()
startTask(String). This method has no effect if no task
is currently started so it's ok to call it more than once.public String formatMillisPerOperation(long theNumOperations)
formatMillis(long)public String formatTaskDurations()
startTask(String)public String formatThroughput(long theNumOperations, TimeUnit theUnit)
For example, if this stopwatch has 2 seconds elapsed, and this method is called for theNumOperations=30 and TimeUnit=SECONDS, this method will return 15
getThroughput(long, TimeUnit)public String getEstimatedTimeRemaining(double theCompleteToDate, double theTotal)
theCompleteToDate - The amount so fartheTotal - The total (must be higher than theCompleteToDatepublic long getMillis()
public long getMillisAndRestart()
public long getMillisPerOperation(long theNumOperations)
theNumOperations - Ok for this to be 0, it will be treated as 1public Date getStartedDate()
public double getThroughput(long theNumOperations, TimeUnit theUnit)
For example, if this stopwatch has 2 seconds elapsed, and this method is called for theNumOperations=30 and TimeUnit=SECONDS, this method will return 15
formatThroughput(long, TimeUnit)public void restart()
public void startTask(String theTaskName)
Thread Safety Note: This method is not threadsafe! Do not use subtasks in a multithreaded environment.
theTaskName - Note that if theTaskName is blank or empty, no task is startedpublic String toString()
formatMillis(long)}
for a description of the formattoString in class ObjectformatMillis(long)public static String formatMillis(long theMillis)
Example outputs:
public static String formatMillis(double theMillis)
Example outputs:
Copyright © 2014–2019 University Health Network. All rights reserved.