]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/Stopwatch.java
Fail safe import fixes made by Antti
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / Stopwatch.java
1 package org.simantics.db.procore.cluster;
2
3 //Simple class for measuring time.
4 public class Stopwatch
5 {
6     public final void start() { // Starts measuring time.
7         start = System.nanoTime();
8     }
9     public final void stop() { // Ends measuring time, increases the amount of elapsed time.
10         time += (double)(System.nanoTime() - start) * (double)(1e-9);
11     }
12     public final void reset() { // Set elapsed time to zero.
13         time = 0;
14     }
15     public final void restart() { // Reset and starts measuring time.
16         this.reset();
17         this.start();
18     }
19     public final double elapsed() { // Returns elapsed time in seconds.
20         return time;
21     }
22     public final double elapsedMilli() { // Returns elapsed time in milliseconds.
23         return time * 1e3;
24     }
25     private long start;
26     private double time;
27 }