summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-05-27 22:29:24 -0700
committerEric Anholt <eric@anholt.net>2011-06-01 11:21:51 -0700
commit030dfc844d7671eed6d6e5c76e4ee6b502571a06 (patch)
treeb220798252ce3658404c27af856385a910990587
parent47d17c6674a16ad96a755967af06a8b7c979514e (diff)
report.pl: Tool to compare the output of run.pl.
-rwxr-xr-xreport.pl105
1 files changed, 105 insertions, 0 deletions
diff --git a/report.pl b/report.pl
new file mode 100755
index 0000000..35af948
--- /dev/null
+++ b/report.pl
@@ -0,0 +1,105 @@
+#!/usr/bin/env perl
+
+my $before_name = $ARGV[0];
+my $after_name = $ARGV[1];
+
+if ($#ARGV != 1) {
+ printf("usage: report.pl <before> <after>\n");
+}
+
+open(BEFORE, $before_name) or die;
+open(AFTER, $after_name) or die;
+
+my %before = ();
+my %after = ();
+
+my $total_programs_before;
+
+while (<BEFORE>) {
+ my $line = $_;
+
+ $line =~ /(.*):(.*)/;
+
+ $before{$1} = $2;
+ $total_programs_before++;
+}
+
+while (<AFTER>) {
+ my $line = $_;
+
+ $line =~ /(.*):(.*)/;
+
+ $after{$1} = $2;
+}
+
+delete $before{"total"};
+delete $after{"total"};
+
+my $total_instructions_before = 0;
+my $total_instructions_after = 0;
+my $affected_programs_before = 0;
+my $affected_instructions_before = 0;
+my $affected_instructions_after = 0;
+
+my %hurt_programs = ();
+
+while (my ($prog, $before_count) = each(%before)) {
+ my $after_count = $after{$prog};
+ if ($after_count == "") {
+ next;
+ }
+
+ $total_instructions_before += $before_count;
+ $total_instructions_after += $after_count;
+
+ if ($before_count == $after_count) {
+ next;
+ }
+
+ if ($after_count > $before_count) {
+ $hurt_programs{$prog} = 1;
+ }
+
+ printf("%s: %4d -> %4d\n",
+ $prog, $before_count, $after_count);
+
+ $affected_instructions_before += $before_count;
+ $affected_instructions_after += $after_count;
+
+ $affected_programs_before++;
+}
+
+printf("\n");
+
+printf("Total instructions: %d -> %d\n",
+ $total_instructions_before, $total_instructions_after);
+
+printf("%d/%d programs affected (%.1f%%)\n",
+ $affected_programs_before, $total_programs_before,
+ 100 * $affected_programs_before / $total_programs_before);
+
+if ($affected_instructions_after < $affected_instructions_before) {
+ printf("%d -> %d instructions in affected programs (%.1f%% reduction)\n",
+ $affected_instructions_before,
+ $affected_instructions_after,
+ 100 - (100 * $affected_instructions_after /
+ $affected_instructions_before));
+}
+
+if ($affected_instructions_after > $affected_instructions_before) {
+ printf("%d -> %d instructions in affected programs (%.1f%% increase)\n",
+ $affected_instructions_before,
+ $affected_instructions_after,
+ (100 * $affected_instructions_after /
+ $affected_instructions_before) - 100);
+}
+
+my $header = 0;
+
+if (keys(%hurt_programs) != 0) {
+ printf("hurt programs:\n");
+
+ while (my ($prog, $junk) = each(%hurt_programs)) {
+ printf("%s\n", $prog);
+ }
+}