如何使用性能统计来计算MIPS [英] How to calculate MIPS using perf stat

查看:708
本文介绍了如何使用性能统计来计算MIPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关基准测试的答案-如何计算发送给CPU的指令数以查找消耗的MIPS 建议:

Linux上的

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

perf stat ./my_program on Linux will use CPU performance counters to record how many instructions it ran, and how many core clock cycles it took. (And how much CPU time it used, and will calculate MIPS for you).


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


An example generates following output which does not contain calculated MIPS information.

 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] 如何从perf stat的输出正确计算MIPS?为了计算MIPS,我应该从perf stat获得的值中遵循instructions/seconds_time_elapsed吗?

[Q] How could I calculate MIPS correctly from output of perf stat? In order to calculate MIPS should I do following instructions/seconds_time_elapsed from the values obtained from perf stat?

推荐答案

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

It's obviously just instructions / seconds. (divided by 1 million to scale for the Mega metric prefix.)

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

Using the total elapsed time will give you MIPS for the whole program, total across all cores, and counting any time spent sleeping / waiting against it.

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

Task-clock will count total CPU time used on all cores, so it will give you the average MIPS across all cores used, not counting any time spent sleeping. (task-clock:u would count only user-space time, but task-clock counts time spent in the kernel as well.)

这篇关于如何使用性能统计来计算MIPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆