由于您拥有 Intel CPU,因此您应该能够使用Processor Counter Monitor,这是一款现已开源的 Intel 软件。如果我没看错的话,在 Linux 上编译它只需要g++和make。
在运行之前,您需要确保msr模块已加载(sudo modprobe msr)或内置。
有了您的 CPU,您应该能够使用该pcm-memory.x实用程序。我不能使用它,所以我不知道输出是什么样子。
即使您的 CPU 不受支持pcm-memory.x,您仍然可以从中获取总体内存带宽统计数据pcm.x。它看起来像这样:
$ sudo ./pcm.x -i=1 -nc\n\n Processor Counter Monitor ($Format:%ci ID=%h$)\n\n\nIBRS and IBPB supported : no\nSTIBP supported : no\nSpec arch caps supported : no\nNumber of physical cores: 4\nNumber of logical cores: 8\nNumber of online logical cores: 8\nThreads (logical cores) per physical core: 2\nNum sockets: 1\nPhysical cores per socket: 4\nCore PMU (perfmon) version: 4\nNumber of core PMU generic (programmable) counters: 4\nWidth of generic (programmable) counters: 48 bits\nNumber of core PMU fixed counters: 3\nWidth of fixed counters: 48 bits\nNominal core frequency: 3600000000 Hz\nPackage thermal spec power: 65 Watt; Package minimum power: 0 Watt; Package maximum power: 0 Watt;\nTrying to use Linux perf events...\nSuccessfully programmed on-core PMU using Linux perf\n\nDetected Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz "Intel(r) microarchitecture codename Kabylake" stepping 9 microcode level 0x5e\n\n EXEC : instructions per nominal CPU cycle\n IPC : instructions per CPU cycle\n FREQ : relation to nominal CPU frequency=\'unhalted clock ticks\'/\'invariant timer ticks\' (includes Intel Turbo Boost)\n 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)\n L3MISS: L3 (read) cache misses\n L2MISS: L2 (read) cache misses (including other core\'s L2 cache *hits*)\n L3HIT : L3 (read) cache hit ratio (0.00-1.00)\n L2HIT : L2 cache hit ratio (0.00-1.00)\n L3MPI : number of L3 (read) cache misses per instruction\n L2MPI : number of L2 (read) cache misses per instruction\n READ : bytes read from main memory controller (in GBytes)\n WRITE : bytes written to main memory controller (in GBytes)\n 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\n TEMP : Temperature reading in 1 degree Celsius relative to the TjMax temperature (thermal headroom): 0 corresponds to the max temperature\n energy: Energy in Joules\n\n\n Core (SKT) | EXEC | IPC | FREQ | AFREQ | L3MISS | L2MISS | L3HIT | L2HIT | L3MPI | L2MPI | TEMP\n\n---------------------------------------------------------------------------------------------------------------\n SKT 0 0.02 1.05 0.02 0.39 402 K 1770 K 0.76 0.53 0.00 0.00 67\n---------------------------------------------------------------------------------------------------------------\n TOTAL * 0.02 1.05 0.02 0.39 402 K 1770 K 0.76 0.53 0.00 0.00 N/A\n\n Instructions retired: 487 M ; Active cycles: 462 M ; Time (TSC): 3602 Mticks ; C0 (active,non-halted) core residency: 4.12 %\n\n C1 core residency: 9.26 %; C3 core residency: 0.59 %; C6 core residency: 2.14 %; C7 core residency: 83.89 %;\n C0 package residency: 36.94 %; C2 package residency: 63.06 %; C3 package residency: 0.00 %; C6 package residency: 0.00 %; C7 package residency: 0.00 %; C8 package residency: 0.00 %; C9 package residency: 0.00 %; C10 package residency: 0.00 %;\n \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n Core C-state distribution\xe2\x94\x820001111111667777777777777777777777777777777777777777777777777777777777777777777\xe2\x94\x82\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n Package C-state distribution\xe2\x94\x8200000000000000000000000000000022222222222222222222222222222222222222222222222222\xe2\x94\x82\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n\n PHYSICAL CORE IPC : 2.11 => corresponds to 52.65 % utilization for cores in active state\n Instructions per nominal CPU cycle: 0.03 => corresponds to 0.85 % core utilization over time interval\n SMI count: 0\n---------------------------------------------------------------------------------------------------------------\nMEM (GB)->| READ | WRITE | IO | CPU energy |\n---------------------------------------------------------------------------------------------------------------\n SKT 0 0.24 0.03 0.00 1.88\n---------------------------------------------------------------------------------------------------------------\nCleaning up\n Zeroed uncore PMU registers\nRun Code Online (Sandbox Code Playgroud)\n\n除非您指定-i=1,否则输出将定期重复。如果省略-nc,您将获得每个核心的执行统计信息,而不仅仅是总数。
在底部,您可以看到内存统计信息。
\n| 归档时间: |
|
| 查看次数: |
2366 次 |
| 最近记录: |