3 # analyse a strace in format given by strace -ttT
4 # Andrew Tridgell <tridge@samba.org> March 2006
5 # released under GNU GPL version 2 or later
15 while (my $line = <>) {
19 if ($line =~ /^(\d+):(\d+):(\d+).(\d+) ([a-z0-9]+)\(.* <(\d[^>]+)/ ||
20 $line =~ /^\d+\s+(\d+):(\d+):(\d+).(\d+) ([a-z0-9]+)\(.* <(\d[^>]+)/) {
21 $clock = ($1 * 3600) + ($2 * 60) + $3 + ($4 * 1.0e-6);
24 $totals{$call} += $time;
27 $cpu{$call} += $clock - $start;
28 $total_cpu += $clock - $start;
30 $start = $clock + $time;
36 CALL time(sec) percent
37 -----------------------------
40 foreach my $c (sort { $totals{$b} <=> $totals{$a} } keys %totals) {
41 printf " %-13s %6.2f %5.2f%%\n", $c, $totals{$c}, 100.0*$totals{$c}/$total,
43 printf(" %-13s %6.2f\n", "TOTAL", $total);
47 -----------------------------
50 foreach my $c (sort { $cpu{$b} <=> $cpu{$a} } keys %cpu) {
51 printf " %-13s %6.2f %5.2f%%\n", $c, $cpu{$c}, 100.0*$cpu{$c}/$total_cpu,
53 printf(" %-13s %6.2f\n", "TOTAL", $total_cpu);