我想为 cpu 时间分析我的 perl 脚本。我发现了 Devel::Nytprof 和 Devel::SmallProf 但第一个不能显示 cpu 时间,第二个工作不好。至少我找不到我需要的东西。
你能为我的目的提供任何工具吗?
UPD:我需要每行分析/因为我的脚本需要很多 cpu 时间,我想改进它的一部分
您可以尝试系统的(不是 shell 的内部!)时间实用程序(前导\
不是错字):
$ \time -v perl collatz.pl
13 40 20 10 5 16 8 4 2 1
23 70 35 106 53 160 80 40
837799 525
Command being timed: "perl collatz.pl"
User time (seconds): 3.79
System time (seconds): 0.06
Percent of CPU this job got: 97%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.94
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 171808
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 9
Minor (reclaiming a frame) page faults: 14851
Voluntary context switches: 16
Involuntary context switches: 935
Swaps: 0
File system inputs: 1120
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0