计时操作

1、Stopwatch watch = Stopwatch.createStarted();
watch.stop();
"耗时:"+watch.elapsed().toMillis()

2、
Instant beginTime = Instant.now();

Instant endTime = Instant.now();

耗时:Duration.between(beginTime, endTime).toMillis() + "ms"

3、long start = System.currentTimeMillis();
long end = System.currentTimeMillis();

耗时: (end - start) ms

猜你喜欢

转载自www.cnblogs.com/sunny-miss/p/10286666.html