mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
Stopwatch class temporary addition to track time of execution easily on very specific parts of code
Signed-off-by: Alex Ebadirad <aebadirad@42six.com>
This commit is contained in:
60
Report/src/org/sleuthkit/autopsy/report/StopWatch.java
Normal file
60
Report/src/org/sleuthkit/autopsy/report/StopWatch.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.report;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alex
|
||||
*/
|
||||
public class StopWatch {
|
||||
|
||||
private long startTime = 0;
|
||||
private long stopTime = 0;
|
||||
private boolean running = false;
|
||||
|
||||
|
||||
public void start() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.running = true;
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
this.stopTime = System.currentTimeMillis();
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
|
||||
//elaspsed time in milliseconds
|
||||
public long getElapsedTime() {
|
||||
long elapsed;
|
||||
if (running) {
|
||||
elapsed = (System.currentTimeMillis() - startTime);
|
||||
}
|
||||
else {
|
||||
elapsed = (stopTime - startTime);
|
||||
}
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
|
||||
startTime = 0;
|
||||
stopTime = 0;
|
||||
running = false;
|
||||
}
|
||||
|
||||
//elaspsed time in seconds
|
||||
public long getElapsedTimeSecs() {
|
||||
long elapsed;
|
||||
if (running) {
|
||||
elapsed = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
}
|
||||
else {
|
||||
elapsed = ((stopTime - startTime) / 1000);
|
||||
}
|
||||
return elapsed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user