首页 > 解决方案 > 我如何解释 simpleperf stat 产生的指令计数,同一线程上的记录不相同?

问题描述

我是一名工程师,在 Android 平台上开发一些东西,因此使用 simpleperf 只是评估线程性能的正常方法。然而最近我陷入了两难境地,我想知道我应该使用哪些统计数据,让我们看看下面的例子:

环境:threadID:27473 运行一个while循环,在后台执行同样的事情

i) >>> simpleperf stat -e 指令 -t 27473 --duration 10 --use-devfreq-counters

Performance counter statistics:

#       count  event_name     # count / runtime,  runtime / enabled_time
  421,117,470  instructions   # 1.349 G/sec  (61%)

Total test time: 10.001907 seconds.
simpleperf W cmd_stat.cpp:863] Percentages < 100% means some events only run a subset of enabled time,
probably caused by hardware counter multiplexing (less counters than events).
Try --use-devfreq-counters if on a rooted device.

ii) >>># simpleperf 记录 -g -t 27473 -e 指令 --duration 10 -o /sdcard/perf.data -f 4000 -m 8192

Event: instructions (type 0, config 1)
Samples: 1688
Event count: 570506200

Overhead   Command    Pid  Tid
570506200  SomeThread  684  27473

我在这里有两个问题:

  1. 为什么在相同的持续时间(10 秒)内监视同一个线程最终会得到完全不同的指令计数,即 421M 与 570M ?哪一个是正确的?
  2. 我注意到第一种方法有61%的百分比,所以我尝试通过这个“NORMALIZE”数据,不知道我是否做得对:421M / 0.61 = 688M,仍然远不符合第二种方法570M,如何我可以校准这两个统计数据吗?

谢谢你救了我

标签: androidperfinstructionsmultiplexing

解决方案


推荐阅读