8 print STDERR
("Error: @_\n");
10 print STDERR
("USAGE:\n");
11 print STDERR
("$0 file1 file2 [showcalldiff]\n");
13 ("\tfile[12] output from profile_reader.pl to compare\n");
15 ("\tshowcalldiff show the percent change in calls instead of ticks\n");
18 if ($ARGV[0] =~ m/-(h|help|-help)/) {
22 usage
("Requires at least 2 arguments");
24 open(FILE1
,shift) || error
("Couldn't open file1");
27 open(FILE2
,shift) || error
("Couldn't open file2");
30 my $showcalldiff = shift;
33 my @calls = (\
%calls1,\
%calls2);
35 my @files = (\
@file1,\
@file2);
38 for ( $i=0; $i <= $#files; $i++ ) {
39 my $file = $files[$i];
40 foreach $line(@
$file) {
42 if ( $line =~ m/By calls/ ) {
46 if ( $line =~ m/By ticks/ ) {
51 my @line = split(/[[:space:]]+/,$line);
52 $allcalls[$i] += $line[1];
53 $allticks[$i] += $line[3];
54 $calls[$i]{$line[5]} = [($line[1],$line[3])];
58 printf("File one calls: %08ld, ticks: %08ld\n",$allcalls[0],$allticks[0]);
59 printf("File two calls: %08ld, ticks: %08ld\n",$allcalls[1],$allticks[1]);
60 printf("Percent change: %+7.2f%%, ticks: %+7.2f%%\n",
61 ($allcalls[1]-$allcalls[0])/$allcalls[0]*100,
62 ($allticks[1]-$allticks[0])/$allticks[0]*100);
63 my @allkeys = keys(%calls1);
64 push(@allkeys,keys(%calls2));
66 my @keys = grep {defined} map {
67 if (exists $u{$_}) { undef; } else { $u{$_}=undef;$_; }
73 my $values1 = $calls1{$key};
74 my $values2 = $calls2{$key};
75 my $calldiff = @
$values2[0]-@
$values1[0];
76 my $totalcalls = @
$values2[0]+@
$values1[0];
77 my $tickdiff = @
$values2[1]-@
$values1[1];
78 my $totalticks = @
$values2[1]+@
$values1[1];
82 $pdiff = $calldiff/(@
$values1[0]>0?@
$values1[0]:1)*100;
83 $result = sprintf("%+7.2f%% Calls: %+09d Symbol: %s$key\n",
85 (exists $calls1{$key} && exists $calls2{$key})?
"":"LONE ");
87 $pdiff = $tickdiff/(@
$values1[1]>0?@
$values1[1]:1)*100;
88 $result = sprintf("%+7.2f%% Ticks: %+09d Symbol: %s$key\n",
90 (exists $calls1{$key} && exists $calls2{$key})?
"":"LONE ");
92 $bycalls{sprintf("%08X$key",$totalcalls)} = $result;
93 $byticks{sprintf("%08X$key",$totalticks)} = $result;
95 my @calls = sort(keys(%bycalls));
97 foreach $call(@calls) {
98 print($bycalls{$call});
100 my @ticks = sort(keys(%byticks));
102 foreach $tick(@ticks) {
103 print($byticks{$tick});