简体   繁体   English

如何将 perf(Linux 工具)的输出保存到文件中?

[英]how to save ouput of perf (Linux tool) to a file?

I want to save results after running perf command, eg.我想在运行 perf 命令后保存结果,例如。

perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &> result1 perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &> result1

I tried a couple of ways, like我尝试了几种方法,例如

    (perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &>result1) > result2
    (perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &>result1) 2> result2
    (perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &>result1) &> result2
    ((perf stat -B dd if=/dev/zero of=/dev/null count=1000000 &>result1) &> result2) > result3

well, none of these actually gave me what I want.好吧,这些实际上都没有给我我想要的。

The result is结果是

Performance counter stats for 'dd if= enter code here /dev/zero of=/dev/null count=1000000': 'dd if= enter code here /dev/zero of=/dev/null count=1000000' 的性能计数器统计信息:

    235.959041 task-clock                #    0.998 CPUs utilized          
            20 context-switches          #    0.000 M/sec                
   .........(too long, dont want to have all of them here)
   0.236448007 seconds time elapsed"

I just want to save these to the file.我只想将这些保存到文件中。

Thanks a lot!!!非常感谢!!!

strace显示perf写入文件描述符 0,所以这应该可以工作:

perf stat -B dd if=/dev/zero of=/dev/null count=1000000 0> result1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM