From 0e95f006b37daea48c8317ba48015d753dbe7f17 Mon Sep 17 00:00:00 2001 From: Alex Ebadirad Date: Tue, 8 May 2012 16:03:20 -0700 Subject: [PATCH] Stopwatch class temporary addition to track time of execution easily on very specific parts of code Signed-off-by: Alex Ebadirad --- .../sleuthkit/autopsy/report/StopWatch.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Report/src/org/sleuthkit/autopsy/report/StopWatch.java diff --git a/Report/src/org/sleuthkit/autopsy/report/StopWatch.java b/Report/src/org/sleuthkit/autopsy/report/StopWatch.java new file mode 100644 index 0000000000..796c3af43e --- /dev/null +++ b/Report/src/org/sleuthkit/autopsy/report/StopWatch.java @@ -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; + } +} \ No newline at end of file