I need stopWatch and I used http://www.goldb.org/stopwatchjava.html
This did not work, so I tried to write a value every 1000 ms:
stopWatch.start(); HandlerScrollBar.postDelayed(TtScroll, 1000); private Runnable TtScroll = new Runnable() { public void run() { long time = stopWatch.getElapsedTime(); HandlerScrollBar.postDelayed(TtScroll,(long) 1000); Log.d(TAG, Long.toString(time)); } };
I can see the time value every second in CatLog, and this is the result:
The real time is max + 5ms, but in the column it is at least +3 seconds! How is this possible? Same thing with
new Date().getTime().
Is there any StopWatch class that will pass this test as expected?
Thanks.
, , System.nanoTime(). System.currentTimeMillis(), , .
System.nanoTime()
System.currentTimeMillis()
nanoTime - , currentTimeMillis - . . , ; .
nanoTime , - . nanoTime(), .
. javadoc:
long startTime = System.nanoTime();
//... ...
long estimatedTime = System.nanoTime() - startTime;
. System.currentTimeMillis(). , Log.d(), logcat Log.e(). , -?
Log.d()
Log.e()