crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

xrprof (695B)


      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 
      5 open (my $if, "/tmp/xr-prof.txt")
      6   or die ("Cannot read /tmp/xr-prof.txt: $!\n");
      7 
      8 my %info;
      9 
     10 while (my $line = <$if>) {
     11     chomp($line);
     12     my (undef, undef, $name, $duration) = split (/\s+/, $line);
     13     # print ("$name: $duration\n");
     14     if ($info{$name}) {
     15 	my ($calls, $total) = @{ $info{$name} };
     16 	$calls++;
     17 	$total += $duration;
     18 	$info{$name} = [ $calls, $total ];
     19     } else {
     20 	$info{$name} = [ 1, $duration ];
     21     }
     22 }
     23 
     24 for my $k (sort bytotal keys(%info)) {
     25     my ($calls, $total) = @{ $info{$k} };
     26     print ("$k: $total usec\n");
     27 }
     28 
     29 sub bytotal {
     30     my @aa = @{ $info{$a} };
     31     my @bb = @{ $info{$b} };
     32     return ($bb[1] <=> $aa[1]);
     33 }
     34