如何在Java程序中获取英特尔CPU上的CPU性能统计数据?
有一个叫做的东西,它给你事件的统计信息,例如如何在Java程序中获取英特尔CPU上的CPU性能统计数据?,java,c++,cpu,intel,performancecounter,Java,C++,Cpu,Intel,Performancecounter,有一个叫做的东西,它给你事件的统计信息,例如 EXEC : instructions per nominal CPU cycle IPC : instructions per CPU cycle FREQ : relation to nominal CPU frequency='unhalted clock ticks'/'invariant timer ticks' (includes Intel Turbo Boost) AFREQ : relation to nominal
EXEC : instructions per nominal CPU cycle
IPC : instructions per CPU cycle
FREQ : relation to nominal CPU frequency='unhalted clock ticks'/'invariant timer ticks' (includes Intel Turbo Boost)
AFREQ : relation to nominal CPU frequency while in active state (not in power-saving C state)='unhalted clock ticks'/'invariant timer ticks while in C0-state' (includes Intel Turbo Boost)
L3MISS: L3 cache misses
L2MISS: L2 cache misses (including other core's L2 cache *hits*)
L3HIT : L3 cache hit ratio (0.00-1.00)
L2HIT : L2 cache hit ratio (0.00-1.00)
L3MPI : number of L3 cache misses per instruction
L2MPI : number of L2 cache misses per instruction
READ : bytes read from memory controller (in GBytes)
WRITE : bytes written to memory controller (in GBytes)
IO : bytes read/written due to IO requests to memory controller (in GBytes); this may be an over estimate due to same-cache-line partial requests
TEMP : Temperature reading in 1 degree Celsius relative to the TjMax temperature (thermal headroom): 0 corresponds to the max temperature
energy: Energy in Joules
Core (SKT) | EXEC | IPC | FREQ | AFREQ | L3MISS | L2MISS | L3HIT | L2HIT | L3MPI | L2MPI | TEMP
0 0 0.10 0.52 0.19 0.74 1502 K 3612 K 0.58 0.53 0.00 0.01 43
1 0 0.19 0.67 0.28 0.80 1548 K 3090 K 0.50 0.69 0.00 0.00 46
2 0 0.06 0.48 0.13 0.73 1060 K 1768 K 0.40 0.57 0.01 0.01 46
3 0 0.07 0.55 0.12 0.72 1142 K 1489 K 0.23 0.47 0.01 0.01 42
4 0 0.06 0.54 0.10 0.75 894 K 2102 K 0.57 0.50 0.00 0.01 43
5 0 0.04 0.49 0.09 0.73 669 K 1377 K 0.51 0.57 0.00 0.01 46
6 0 0.03 0.43 0.08 0.73 888 K 1543 K 0.42 0.30 0.01 0.01 46
7 0 0.24 0.80 0.29 0.90 1285 K 2132 K 0.40 0.78 0.00 0.00 42
---------------------------------------------------------------------------------------------------------------
SKT 0 0.10 0.61 0.16 0.78 8992 K 17 M 0.47 0.61 0.00 0.01 42
---------------------------------------------------------------------------------------------------------------
TOTAL * 0.10 0.61 0.16 0.78 8992 K 17 M 0.47 0.61 0.00 0.01 N/A
Instructions retired: 2702 M ; Active cycles: 4420 M ; Time (TSC): 3411 Mticks ; C0 (active,non-halted) core residency: 20.75 %
C1 core residency: 21.34 %; C3 core residency: 11.65 %; C6 core residency: 46.26 %; C7 core residency: 0.00 %;
C2 package residency: 0.00 %; C3 package residency: 0.00 %; C6 package residency: 0.00 %; C7 package residency: 0.00 %;
PHYSICAL CORE IPC : 1.22 => corresponds to 30.57 % utilization for cores in active state
Instructions per nominal CPU cycle: 0.20 => corresponds to 4.95 % core utilization over time interval
---------------------------------------------------------------------------------------------------------------
| READ | WRITE | IO | CPU energy |
---------------------------------------------------------------------------------------------------------------
SKT 0 2.03 0.94 1.31 18.18
---------------------------------------------------------------------------------------------------------------
现在,这个软件也有从程序内部调用的选项。如果您调用该程序中的某些函数,它将提供这些函数的统计信息,如示例中所示。我的问题是所有的软件、库和代码部分都是为C++编写的。当我在互联网上搜索时,一些人聚集在一起,打开了一个开源项目,作为Java性能计数器监视器。然而,该项目最后一次更新是在2011-2012年,即使该网站是在Sun下构建的,也不确定它是否能在Java8下工作
我的问题是有没有性能分析程序或如何使用IPCM来实现java程序?C++可以使用JNI使用C++库。您可以阅读有关如何在StackOverflow上执行此操作的更多信息。德国劳埃德船级社。这会给统计数据带来开销吗?我的意思是,我希望尽可能地看到我的程序的统计数据,这个方法会改变统计数据这么多吗?如果它对如何折射有任何建议,那么就尽可能多。要求我们推荐或查找书籍、工具、软件库、教程或其他非现场资源的问题与堆栈溢出无关。试试@Stack Exchange。它看起来像是英特尔性能监视器写入操作系统;然后是用户空间,Intel提供了从那里读取的库。换句话说,它看起来像是从中读取的Linux库,从中读取的Windows库,等等。对您来说,一种可能性是JNI,也许更好的可能性是针对特定于操作系统的性能计数器的Java库。我个人认为开销是最小的。我还认为,由于JAVA打算在多个平台上运行,因此没有独立于平台的方法来衡量CPU性能。因此,我认为除了使用JNI/JNA使用本机库之外,可能没有其他方法(尽管我可能错了)。如果您仍然想使用JAVA库,我建议您遵循Obvlious船长的建议。德国劳埃德船级社!