mirror of
https://gitlab.com/harald.mueller/aktuelle.kurse.git
synced 2024-11-30 21:51:56 +01:00
31 lines
484 B
Java
31 lines
484 B
Java
|
|
||
|
/**
|
||
|
* Used from the book by R. Sedgwick.
|
||
|
* @author littleJ
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
public class Stopwatch {
|
||
|
|
||
|
|
||
|
|
||
|
private final long start;
|
||
|
|
||
|
/**
|
||
|
* Create a stopwatch object.
|
||
|
*/
|
||
|
public Stopwatch() {
|
||
|
start = System.currentTimeMillis();
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Return elapsed time (in seconds) since this object was created.
|
||
|
*/
|
||
|
public double elapsedTime() {
|
||
|
long now = System.currentTimeMillis();
|
||
|
return (now - start) / 1000.0;
|
||
|
}
|
||
|
|
||
|
}
|