diff options
Diffstat (limited to 'java/src/IceUtilInternal/StopWatch.java')
-rw-r--r-- | java/src/IceUtilInternal/StopWatch.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/java/src/IceUtilInternal/StopWatch.java b/java/src/IceUtilInternal/StopWatch.java new file mode 100644 index 00000000000..de531a50330 --- /dev/null +++ b/java/src/IceUtilInternal/StopWatch.java @@ -0,0 +1,42 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceUtilInternal; + +public class StopWatch +{ + public void + start() + { + _s = System.nanoTime(); + } + + public long + stop() + { + assert(isStarted()); + long d = (System.nanoTime() - _s) / 1000; + _s = 0; + return d; + } + + public boolean + isStarted() + { + return _s != 0; + } + + public long + delay() + { + return (System.nanoTime() - _s) / 1000; + } + + private long _s = 0; +}; |