Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
StopWatch.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 package org.sleuthkit.autopsy.coreutils;
21 
25 public class StopWatch {
26 
27  private long startTime = 0;
28  private long stopTime = 0;
29  private boolean running = false;
30 
31 
32  public void start() {
33  this.startTime = System.currentTimeMillis();
34  this.running = true;
35  }
36 
37 
38  public void stop() {
39  this.stopTime = System.currentTimeMillis();
40  this.running = false;
41  }
42 
43 
44  //elaspsed time in milliseconds
45  public long getElapsedTime() {
46  long elapsed;
47  if (running) {
48  elapsed = (System.currentTimeMillis() - startTime);
49  }
50  else {
51  elapsed = (stopTime - startTime);
52  }
53  return elapsed;
54  }
55 
56  public void reset(){
57 
58  startTime = 0;
59  stopTime = 0;
60  running = false;
61  }
62 
63  //elaspsed time in seconds
64  public long getElapsedTimeSecs() {
65  long elapsed;
66  if (running) {
67  elapsed = ((System.currentTimeMillis() - startTime) / 1000);
68  }
69  else {
70  elapsed = ((stopTime - startTime) / 1000);
71  }
72  return elapsed;
73  }
74 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.