KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > foundation > StopWatch


1 //Prevayler(TM) - The Free-Software Prevalence Layer.
2
//Copyright (C) 2001-2003 Klaus Wuestefeld
3
//This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4

5 package org.prevayler.foundation;
6
7 public class StopWatch {
8
9     private final long t0 = System.currentTimeMillis();
10
11     static public StopWatch start() {
12         return new StopWatch();
13     }
14
15     public long millisEllapsed() {
16         return System.currentTimeMillis() - t0;
17     }
18
19     public double secondsEllapsed() {
20         return millisEllapsed() / 1000.0;
21     }
22
23     private StopWatch() {
24     }
25 }
26
Popular Tags