Performance Monitoring Tools for Linux (perf)
Performance Monitoring Tools for Linux (perf) เครื่องมือที่ใช้ในการวิเคราะห์และวัดประสิทธิภาพสำหรับลินุกซ์เคอร์เนล (Linux 2.6 +) และการเปรียบเทียบประสิทธิภาพความแตกต่างของฮาร์ดแวร์ โดยการระบุอินเตอร์เฟช (pert_events)
ติดตั้งโปรแกรม Perf (Installing Perf on openSUSE 12.1)
[sourcecode]
zypper in perf
[/sourcecode]
รูปแบบการใช้คำสั่ง
perf [–version] [–help] COMMAND [ARGS]
ตัวอย่าง command
– List of options for each command
[sourcecode]
perf stat -h
[/sourcecode]
– List of supported devents
[sourcecode]
perf list
[/sourcecode]
ตัวอย่าง การทดสอบภาระการทำงานหลายๆ ครั้งเหมือนกัน (workload multiple)
[sourcecode]
perf stat -r 5 sleep 1
[/sourcecode]
ตัวอย่าง เอาท์พุทแสดงค่าเฉลี่ยนแต่ละเหตุการณ์
[sourcecode]
Performance counter stats for ‘sleep 1’ (5 runs):
1.931412 task-clock # 0.002 CPUs utilized ( +- 2.55% )
1 context-switches # 0.001 M/sec ( +- 17.50% )
1 CPU-migrations # 0.000 M/sec ( +- 66.67% )
170 page-faults # 0.088 M/sec ( +- 0.12% )
573,741 cycles # 0.297 GHz ( +- 41.86% )
0 stalled-cycles-frontend # 0.00% frontend cycles idle ( +- 0.00% )
0 stalled-cycles-backend # 0.00% backend cycles idle ( +- 0.00% ) [37.95%]
1,969,162 instructions # 3.43 insns per cycle ( +- 3.00% ) [39.09%]
356,374 branches # 184.515 M/sec ( +- 5.39% ) [39.09%]
<not counted> branch-misses
1.002559022 seconds time elapsed ( +- 0.01% )
[/sourcecode]
โดยค่าเริ่มต้นแล้ว perf stat จะแสดง counts ทั้งหมดของทุกๆ threads process และ subsequent child processes เราสามารถใช้ออบชั่น (-i) ในการระบุ thread ได้ (per-thread, per-process, per-cpu, system-wide)
ตัวอย่าง perf stat counts ในโหมด per-thread โดยใช้ออบชั่น -a (per-cpu)
[sourcecode]
perf stat -B -ecycles:u,instructions:u -a dd if=/dev/zero of=/dev/null count=2000000
[/sourcecode]
ตัวอย่าง เอาท์พุทที่ได้
[sourcecode]
2000000+0 records in
2000000+0 records out
1024000000 bytes (1.0 GB) copied, 3.3646 s, 304 MB/s
Performance counter stats for ‘dd if=/dev/zero of=/dev/null count=2000000’:
17,366,736,982 cycles:u # 0.000 GHz [100.00%]
1,658,480,831 instructions:u # 0.10 insns per cycle
3.367921247 seconds time elapsed
[/sourcecode]