Updated function for performance

This commit is contained in:
2020-06-12 15:03:04 -04:00
parent bef70b685b
commit 1e4cb3316e

View File

@@ -50,10 +50,10 @@ public class Stopwatch{
private enum TIME_RESOLUTION{ NANOSECOND, MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR, ERROR }
//Simulates starting a stopwatch by saving the time
public void start(){
//Get the time as close to calling the function as possible
startTime = System.nanoTime();
//Make sure the stop time is reset to 0
stopTime = null;
//Get the time as close to returning from the function as possible
startTime = System.nanoTime();
}
//SImulates stoping a stopwatch by saving the time
public void stop(){
@@ -98,7 +98,8 @@ public class Stopwatch{
public String getStr(){
//Get the current duration from time
Double duration = getTime().doubleValue();
//Reduce the number to the appropriate number of digits. (xxx.x). This loop works down to seconds
//Reduce the number to the appropriate number of digits. (xxx.x).
//This loop works down to seconds
TIME_RESOLUTION resolution;
for(resolution = TIME_RESOLUTION.NANOSECOND;(resolution.ordinal() < TIME_RESOLUTION.SECOND.ordinal()) && (duration >= 1000);resolution = TIME_RESOLUTION.values()[resolution.ordinal() + 1]){
duration /= 1000;