diff options
Diffstat (limited to 'src/jake2/sys/HighPrecisionTimer.java')
-rw-r--r-- | src/jake2/sys/HighPrecisionTimer.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/jake2/sys/HighPrecisionTimer.java b/src/jake2/sys/HighPrecisionTimer.java new file mode 100644 index 0000000..a8a0201 --- /dev/null +++ b/src/jake2/sys/HighPrecisionTimer.java @@ -0,0 +1,32 @@ +/* + * HighPrecisionTimer.java + * Copyright (C) 2005 + * + * $Id: HighPrecisionTimer.java,v 1.1 2005-07-01 14:11:00 hzi Exp $ + */ +package jake2.sys; + +import sun.misc.Perf; + + + + +class HighPrecisionTimer extends Timer { + + private Perf perf = Perf.getPerf(); + private double f = 1000.0 / perf.highResFrequency(); + private long base; + + HighPrecisionTimer() { + base = perf.highResCounter(); + } + + public long currentTimeMillis() { + long time = perf.highResCounter(); + long delta = time - base; + if (delta < 0) { + delta += Long.MAX_VALUE + 1; + } + return (long)(delta * f); + } +} |