当我想使用来自Linux工具套件perf的 perf-stat和perf-report生成性能报告时,我运行:
$ perf record -o my.perf.data myCmd
$ perf report -i my.perf.data
Run Code Online (Sandbox Code Playgroud)
和:
$ perf stat myCmd
Run Code Online (Sandbox Code Playgroud)
但这意味着我第二次运行'myCmd',这需要几分钟.相反,我希望:
$ perf stat -i my.perf.data
Run Code Online (Sandbox Code Playgroud)
但与perf套件中的大多数工具不同,我没有看到perf-stat的-i选项.是否有其他工具,或者获取perf-report以生成与perf-stat相似的输出的方法?
我想在我的新Galaxy S4手机上获得一些基本的性能数据.我已经编译了一个自定义内核并设法使用Odin将其闪存到设备上.这些是我启用的与perf工具相关的内核模块:
CONFIG_HAVE_PERF_EVENTS=y
CONFIG_PERF_USE_VMALLOC=y
CONFIG_PERF_EVENTS=y
CONFIG_PERF_COUNTERS=y
Run Code Online (Sandbox Code Playgroud)
我还交叉编译了perf工具.问题是当我运行以下命令时:
perf stat ls
Run Code Online (Sandbox Code Playgroud)
输出似乎不太正确:
Performance counter stats for 'ls':
10887392 cycles # 0.000 Ghz
0 instructions # 0.00 insns per cycle
0.012448321 seconds time elapsed
Run Code Online (Sandbox Code Playgroud)
我已经将cpu策略设置为'userspace'并且执行了:
cpufreq-set -f 1600000
Run Code Online (Sandbox Code Playgroud)
为了确保所有核心始终以最大频率工作.
我将不胜感激任何帮助.
以下是没有解决方案的类似案例的链接:http : //lists.linaro.org/pipermail/linaro-kernel/2012-December/002611.html http://forums.arm.com/index.php?/topic/ 15020-PMU功能于Cortex-A8的的OMAP-3530-什么-AM-I-做,错了/
相关的stackoverflow主题: 如何在ARM Cortex-A8处理器中测量程序执行时间?
我试图用perf kvm监视客户操作系统.我使用perf kvm record选项记录了性能,并使用perf kvm报告生成了报告.对于记录和报告,我使用的客户机操作系统kallsyms和模块作为解释在这里.
问题是,当我使用perf kvm报告生成报告时,很多"共享对象"都是未知的,因为perf kvm报告无法找到符号.下面是我运行报告时的终端输出.
root@computer1:/# perf kvm --guest --guestmodules=modules report -i perf.data --force > waste
Failed to open [ext4], continuing without symbols
Failed to open [jbd2], continuing without symbols
Failed to open [virtio_blk], continuing without symbols
Failed to open [dm_mod], continuing without symbols
Failed to open [virtio_pci], continuing without symbols
Failed to open [virtio_ring], continuing without symbols
Run Code Online (Sandbox Code Playgroud)
下面是输出的一部分,我重定向到一个文件,你可以很容易地看到'未知'.
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost …Run Code Online (Sandbox Code Playgroud) 我使用linux perf(perf_events)生成带有时间戳的perf.data文件.
如何在子时间间隔[i-start,i-end]中生成所有事件的报告?
我可以将perf.data缩小到只包含[i-start,i-end]中的事件的perf_subinterv.data文件吗?
我需要这样做来分析每5分钟左右性能不佳的短间隔(2s - 6s).
我在Haswell CPU(Intel Core i7-4790)上安装了perf.但是"性能列表"不包括"停滞 - 循环 - 前端"和"停滞循环 - 后端".我检查了http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html,但没有找到与表19中的停滞循环后端相关的性能事件 - 7(第四代英特尔酷睿处理器的处理器核心中的非架构性能事件).
所以我的问题是:如何使用Haswell CPU内核中的perf或其他工具来测量停滞循环后端.内核是3.19,perf版本也是3.19.
谢谢
我注意到,perf list现在可以选择测量功耗。您可以按以下方式使用它:
$ perf stat -e power/energy-cores/ ./a.out
Performance counter stats for 'system wide':
8.55 Joules power/energy-cores/
0.949871058 seconds time elapsed
Run Code Online (Sandbox Code Playgroud)
此测量的准确度如何,性能如何估计功耗?
我使用 linux perf 来分析我的程序,但我无法理解结果。
10.5% 2 乐趣 .....................
|
|- 80% - ABC
| call_ABC
-- 20% - 防御
调用_DEF
上面的例子意味着 'fun' 有两个样本并且贡献了 10.5% 的开销,
其中80%来自ABC,20%来自DEF。我对吗?
现在我们只有两个样本,那么'perf'如何计算ABC和DEF的分数?
为什么不是 50%?剂量'perf'使用附加信息?
我运行以下调用 perf_event_open 系统调用的程序:Linux sama-desktop 3.18.0-20-rpi2 #21-Ubuntu SMP PREEMPT Sun Apr 5 01:56:02 UTC 2015 armv7l armv7l armv7l GNU/Linux
该程序:
#define _GNU_SOURCE 1
#include <asm/unistd.h>
#include <fcntl.h>
#include <linux/perf_event.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
long perf_event_open(struct perf_event_attr* event_attr, pid_t pid, int cpu, int group_fd, unsigned long flags)
{
return syscall(__NR_perf_event_open, event_attr, pid, cpu, group_fd, flags);
}
static void perf_event_handler(int signum, siginfo_t* info, void* ucontext) {
if(info->si_code != POLL_HUP) {
// Only POLL_HUP should happen.
exit(EXIT_FAILURE);
}
ioctl(info->si_fd, PERF_EVENT_IOC_REFRESH, …Run Code Online (Sandbox Code Playgroud) 我知道“perf”工具需要安装对应于特定 linux 内核版本。而且我知道所有 docker 映像都使用相同的 linux 内核版本运行,无论 linux 发行版是什么。
我在 docker 中使用 ubuntu 16.04 并且已经安装了 linux-tools-common,启动性能告诉我我仍然缺少一些软件包:'
# perf
/usr/bin/perf: line 32: lsb_release: command not found
WARNING: perf not found for kernel 4.9.12
You may need to install the following packages for this specific kernel:
linux-tools-4.9.12-moby
linux-cloud-tools-4.9.12-moby
You may also want to install one of the following packages to keep up to date:
linux-tools-moby
linux-cloud-tools-moby
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装我错过的东西:
root@xxxxxx:/# apt-get install linux-tools-4.9.12-moby linux-cloud-tools-4.9.12-moby
Reading package lists... Done
Building dependency tree
Reading state information... …Run Code Online (Sandbox Code Playgroud) 我使用以下开关编译了我的 C++ 代码:
g++ -O0 -g -rdynamic -DNDEBUG -DARMA_NO_DEBUG -std=c++11 -pthread
Run Code Online (Sandbox Code Playgroud)
链接器开关是:
-lboost_system -lboost_thread -lboost_chrono -larmadillo -pthread
Run Code Online (Sandbox Code Playgroud)
但是我在我的应用程序中没有使用线程。我也避免使用任何delay函数。
然后我运行代码并使用perf工具对其进行测试。
sudo perf record ./bin/my_application
sudo perf report -f
Run Code Online (Sandbox Code Playgroud)
结果对我来说很奇怪:
Overhead Command Shared Object Symbol
50.92% myApplication [kernel.kallsyms] [k] native_sched_clock
24.73% myApplication [kernel.kallsyms] [k] pick_next_entity
17.46% myApplication [kernel.kallsyms] [k] prepend_name
2.57% myApplication myApplication [.] arma::arrayops::copy_small<double>
1.11% myApplication myApplication [.] arma::Mat<double>::Mat
1.11% myApplication myApplication [.] myClass::myMethod
1.11% myApplication libblas.so.3 [.] dgemv_
0.97% myApplication myApplication [.] arma::Mat<double>::init_cold
Run Code Online (Sandbox Code Playgroud)
为什么 kernel.kallsyms函数主宰了执行时间? …