如何使用性能统计信息计算MIPS

时间:2018-11-18 16:47:47

标签: performance profiling mips cpu perf

answer about Benchmarking - How to count number of instructions sent to CPU to find consumed MIPS之后,建议:

  Linux上的

perf stat ./my_program将使用CPU性能计数器   记录它运行了多少条指令,以及它有多少个核心时钟周期   拿。 (以及它使用了多少CPU时间,并将为   你)。


一个示例生成以下输出,其中不包含计算出的MIPS信息。

 Performance counter stats for './hello.py':

       1452.607792 task-clock (msec)         #    0.997 CPUs utilized
               327 context-switches          #    0.225 K/sec
               147 cpu-migrations            #    0.101 K/sec
            35,548 page-faults               #    0.024 M/sec
     2,254,593,107 cycles                    #    1.552 GHz                     [26.64%]
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
     1,652,281,933 instructions              #    0.73  insns per cycle         [38.87%]
       353,431,039 branches                  #  243.308 M/sec                   [37.95%]
        18,536,723 branch-misses             #    5.24% of all branches         [38.06%]
       612,338,241 L1-dcache-loads           #  421.544 M/sec                   [25.93%]
        41,746,028 L1-dcache-load-misses     #    6.82% of all L1-dcache hits   [25.71%]
        25,531,328 LLC-loads                 #   17.576 M/sec                   [26.39%]
         1,846,241 LLC-load-misses           #    7.23% of all LL-cache hits    [26.26%]

       1.456531157 seconds time elapsed

[Q] 如何从MIPS的输出中正确计算出perf stat?为了计算MIPS,我应该从instructions/seconds_time_elapsed获得的值中遵循perf stat吗?

1 个答案:

答案 0 :(得分:2)

显然只是指令/秒。 (除以一百万以扩展为兆度量标准前缀。)

使用总耗时将为您提供整个程序的MIPS,所有内核的总计,并计算睡眠/等待它所花费的任何时间。

Task-clock将计算所有内核上使用的CPU总时间,因此它将为您提供所有使用的所有内核上的平均值 MIPS,而不计算任何睡眠时间。 (task-clock:u只计算用户空间时间,而task-clock也计算在内核中花费的时间。)

相关问题