aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/sys/Timer.java
blob: 683e6b667fc6c0a119d4e572247bdd9b944f1af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Timer.java
 * Copyright (C) 2005
 * 
 * $Id: Timer.java,v 1.2 2005-07-01 14:20:54 hzi Exp $
 */
package jake2.sys;

import jake2.Globals;
import jake2.qcommon.Com;


public abstract class Timer {

	abstract public long currentTimeMillis();
	private static long time = 0;
	
	static Timer t;
	
	static {
		try {
			t = new NanoTimer();
		} catch (Throwable e) {
			try {
				t = new HighPrecisionTimer();
			} catch (Throwable e1) {
				t = new StandardTimer();
			}
		}
		Com.Println("using " + t.getClass().getName());
	}
	
	public static int Milliseconds() {
		return Globals.curtime = (int)(t.currentTimeMillis());
	}
}