jtop cpu 秒

发布于 2024-11-18 22:20:55 字数 199 浏览 9 评论 0原文

我在 VisualVM 中使用 JConsole 的 JTOP 插件。这是我的CPU(秒)使用情况。我试图理解这句话的意思,是吗?

  • a) 头部的时间(以秒为单位) CPU 的运行。
  • b) 时间(以秒为单位) 第一个线程开始运行 时间(它可能不会一直运行)
  • c) 其他时间?

感谢期待。

I am using JTOP plugin of JConsole in VisualVM. It somes me the CPU(secs) usage. I am trying to understand the meaning of this, is it?

  • a) Time (in secs) the theead is
    running of CPU.
  • b) Time (in secs) the
    thread started running for the first
    time (it might not be running always)
  • c) Some other time?

Thanks in anticipation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城缀染半城烟沙 2024-11-25 22:20:55

如果您指的是 JDK 发行版的 demo/management 文件夹中的 JTop Jconsole 插件:
它使用 ThreadMXBean.getThreadCpuTime(long) 来获取 cpu 时间。该方法的 javadoc 指出:

返回指定 ID 的线程的总 CPU 时间(以纳秒为单位)。返回值具有纳秒精度,但不一定是纳秒精度。如果实现区分用户模式时间和系统模式时间,则返回的CPU时间是线程在用户模式或系统模式下执行的时间量。

如果指定ID的线程不存在或者不存在,则该方法返回-1。如果禁用 CPU 时间测量,则此方法返回 -1。如果线程已启动且尚未死亡,则该线程处于活动状态。

如果在线程启动后启用 CPU 时间测量,Java 虚拟机实现可以选择任何时间(包括启用该功能的时间)作为 CPU 时间测量的开始点。

退货:
如果指定 ID 的线程存在、该线程处于活动状态并且启用了 CPU 时间测量,则指定 ID 的线程的总 CPU 时间;否则-1。

该值在放入表中之前由插件除以 10E9,因此您可以看到进程使用 CPU 的时间量(以秒为单位)。

If you mean the JTop Jconsole plugin from the demo/management folder of the JDK distribution:
It uses ThreadMXBean.getThreadCpuTime(long) to get the cpu time. The javadoc for this method states:

Returns the total CPU time for a thread of the specified ID in nanoseconds. The returned value is of nanoseconds precision but not necessarily nanoseconds accuracy. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the thread has executed in user mode or system mode.

If the thread of the specified ID is not alive or does not exist, this method returns -1. If CPU time measurement is disabled, this method returns -1. A thread is alive if it has been started and has not yet died.

If CPU time measurement is enabled after the thread has started, the Java virtual machine implementation may choose any time up to and including the time that the capability is enabled as the point where CPU time measurement starts.

Returns:
the total CPU time for a thread of the specified ID if the thread of the specified ID exists, the thread is alive, and CPU time measurement is enabled; -1 otherwise.

This value is divided by 10E9 by the plugin before put into the table, so you see the amount of Time the process was using the CPU in seconds.

醉城メ夜风 2024-11-25 22:20:55

我想说的是a),即。到目前为止线程在 CPU 上运行所花费的时间。

它实际上是 ThreadMXBean 的 ui。

来自该 JavaDoc:

如果实现区分用户模式时间和系统模式时间,则返回的 CPU 时间是当前线程在用户模式或系统模式下执行的时间量。

这意味着总体 CPU 时间也是执行时间。

I'd say it's a), ie. the time the thread spent running on the CPU so far.

It's actually a ui for ThreadMXBean.

From that JavaDoc:

If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the current thread has executed in user mode or system mode.

This implies that overall CPU time is also the execution time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文