如何衡量Java线程执行时间? [英] How to measure Java thread execution time?

查看:217
本文介绍了如何衡量Java线程执行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Java测量线程执行时间。现在我正在监视线程的开始和结束时间,但我认为它不是那么准确,因为线程可能在执行期间被暂停。

I want to measure thread execution time in Java. Now I'm monitoring thread start and end times, but I think it's not so accurate because thread could be suspended during it execution.

推荐答案

<这>不重要。最好的办法是使用一个可以累积实际CPU周期的分析器。

This is nontrivial. Your best bet is to use a profiler which can accumulate the actual CPU cycles used.

这篇关于如何衡量Java线程执行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆