| 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(long val)
Formats a number of milliseconds for display (e.g.
|
String |
formatTaskDurations()
Returns a string providing the durations of all tasks collected by
startTask(String) |
String |
formatThroughput(int 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() |
int |
getMillisPerOperation(int theNumOperations) |
Date |
getStartedDate() |
double |
getThroughput(int 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 formatTaskDurations()
startTask(String)public String formatThroughput(int 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(int, 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 int getMillisPerOperation(int theNumOperations)
theNumOperations - Ok for this to be 0, it will be treated as 1public Date getStartedDate()
public double getThroughput(int 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(int, 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 val)
Example outputs:
Copyright © 2014–2018 University Health Network. All rights reserved.