01: /*
02:  * Harcanan zamani olcmeye yarayan siniftir.
03:  * Real's Java site (http://www.rgagnon.com) sitesinden
04:  * alinmistir. 
05:  * @author Ral Gagnon
06:  */
07: final class Timer {
08:   private long start;
09:   private long end;
10: 
11:   public Timer() {
12:     reset();
13:     }
14: 
15:   public void start() {
16:     System.gc();
17:     start = System.currentTimeMillis();
18:     }
19: 
20:   public void end() {
21:     System.gc();
22:     end = System.currentTimeMillis();
23:     }
24: 
25:   public long duration(){
26:     return (end-start);
27:     }
28: 
29:   public void reset() {
30:     start = 0;  end   = 0;
31:     }
32: 
33:   public static void main(String s[]) {
34:     // simple example
35:     Timer t = new Timer();
36:     t.start();
37:     for (int i=0; i < 80; i++){ System.out.print(".");}
38:     t.end();
39:     System.out.println("\n" + t.duration());
40:     }
41:  }