KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > util > Timer


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.util;
5
6 public class Timer
7 {
8   public long start;
9   public long end;
10   
11   public void start()
12   {
13     start = System.currentTimeMillis();
14   }
15   
16   public void stop()
17   {
18     end = System.currentTimeMillis();
19   }
20   
21   public long elapsed()
22   {
23     return end - start;
24   }
25   
26   public float tps(long t)
27   {
28     return (float) t / elapsed() * 1000;
29   }
30 }
31
Popular Tags