Re: Hmmmm.

From: Michael O'Reilly <michael@dont-contact.us>
Date: Tue, 18 Mar 1997 14:57:19 +0800

In message <199703180829.KAA12933@linkage.ctech.ac.za>, Jacques Hugo writes:
> > Food for thought. This is a profiling of real time (i.e. wall clock
> > time) consumed per system call (this was generated with the use of
> > strace, and a bit of perl).
> [snip]
>
> >
> > <system call> <#1> <#2> <#3> <#4>
> >
> > bind 25 0.0134 0.000537 0.00006
> > stat 10 0.0262 0.002620 0.00012
> [snip]
>
> > comments?
>
> Yes, looks like a nifty perl script. Mind mailing it to the list?

It's pretty simple, and probably linux specific.

I take an strace with..
        strace -o file -tt -T -p <squid PID>
and then just do
        elapcount < file
where elapcount is the perl script below.

#! /usr/bin/perl
$line = <>;
$line =~ /^..:..:([^ ]*) ([a-z]*)\(/;
($t, $syscall) = ($1, $2);

while (<>) {
        /^..:..:([^ ]*) ([a-z]*)\(/ || next;
        $diff = $1 - $t;
        $diff += 60 if ($diff < 0);
        $map{$syscall} += $diff;
        $count{$syscall} ++;
        $total += $diff;

        $syscall = $2; $t = $1;
}
foreach $i (sort { $map{$a} <=> $map{$b} } keys %map) {
        printf "%20s %5d %10.4f %10.6f %2.5f\n",
                $i, $count{$i}, $map{$i},
                $map{$i} / $count{$i},
                $map{$i} / $total;
}
print "Total time elapsed: $total\n";
Received on Mon Mar 17 1997 - 23:16:23 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:43 MST