如何分析程序在睡眠或IO操作中花费的时间

时间:2022-04-27 00:29:25

I know how to profile CPU/Memory. But now I need to profile some code which uses IO operations (PlainSocketImpl.doConnect and others) to understand which piece of code is taking most of the time.

我知道如何配置CPU /内存。但是现在我需要分析一些使用IO操作的代码(PlainSocketImpl.doConnect和其他代码),以了解大部分时间内哪些代码占用。

2 个解决方案

#1


2  

JProfiler has file and sockets probes that show you I/O data around the actual objects.

JProfiler具有文件和套接字探针,可以显示实际对象周围的I / O数据。

如何分析程序在睡眠或IO操作中花费的时间

In the CPU views there is a thread selector that has a "Net I/O" state. If you select that state, you will only see times spent in I/O.

在CPU视图中,有一个具有“Net I / O”状态的线程选择器。如果选择该状态,则只会看到在I / O中花费的时间。

如何分析程序在睡眠或IO操作中花费的时间

Disclaimer: My company develops JProfiler.

免责声明:我公司开发JProfiler。

#2


3  

On linux based systems you can try iotop. Switch the view to show threads, then combine it with jstack outputs to match actual lines of code.

在基于Linux的系统上,您可以尝试iotop。切换视图以显示线程,然后将其与jstack输出组合以匹配实际的代码行。

Not very automatic though.

虽然不是很自动。

#1


2  

JProfiler has file and sockets probes that show you I/O data around the actual objects.

JProfiler具有文件和套接字探针,可以显示实际对象周围的I / O数据。

如何分析程序在睡眠或IO操作中花费的时间

In the CPU views there is a thread selector that has a "Net I/O" state. If you select that state, you will only see times spent in I/O.

在CPU视图中,有一个具有“Net I / O”状态的线程选择器。如果选择该状态,则只会看到在I / O中花费的时间。

如何分析程序在睡眠或IO操作中花费的时间

Disclaimer: My company develops JProfiler.

免责声明:我公司开发JProfiler。

#2


3  

On linux based systems you can try iotop. Switch the view to show threads, then combine it with jstack outputs to match actual lines of code.

在基于Linux的系统上,您可以尝试iotop。切换视图以显示线程,然后将其与jstack输出组合以匹配实际的代码行。

Not very automatic though.

虽然不是很自动。