System.currentTimeMillis spa
精準度:mscode
返回:當前時間與1970年1月1日之間的毫秒差blog
優缺:class
`精度和準確度可能不夠thread
`更改系統時間會影響結果sed
long start = System.currentTimeMillis(); //do something long end = System.currentTimeMillis();
System.nanoTimebug
精準度:ns程序
返回:當前系統(程序)計時器的精確值(ns)im
優缺:di
`沒有定義參考時間,只能用來測量時間間隔
long start = System.nanoTime(); //do something long end = System.nanoTime();
更多:
Debug.threadCpuTimeNanos
SystemClock.currentThreadTimeMills
SystemClock.elapsedRealTime
SystemClock.upTimeMills