[llvm-commits] CVS: llvm/test/Programs/Makefile.TEST.dsgraph generate_report.pl
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 17 16:17:01 PST 2003
Changes in directory llvm/test/Programs:
Makefile.TEST.dsgraph updated: 1.2 -> 1.3
generate_report.pl updated: 1.2 -> 1.3
---
Log message:
Genericize generate_report.pl
---
Diffs of the changes:
Index: llvm/test/Programs/Makefile.TEST.dsgraph
diff -u llvm/test/Programs/Makefile.TEST.dsgraph:1.2 llvm/test/Programs/Makefile.TEST.dsgraph:1.3
--- llvm/test/Programs/Makefile.TEST.dsgraph:1.2 Fri Jan 17 14:09:44 2003
+++ llvm/test/Programs/Makefile.TEST.dsgraph Fri Jan 17 16:16:41 2003
@@ -38,7 +38,6 @@
@echo "---------------------------------------------------------------"
@cat $<
-
#
# Rules for building a report from 'make report TEST=dsgraph' at Programs level
#
@@ -49,9 +48,7 @@
## FIXME: This should be genericized and put into Programs/Makefile as a nice
## report target.
report: report.raw.out
- ./generate_report.pl report.raw.out > report.txt
- @head -n1 report.txt
- @sed '/^Name:/d' < report.txt | sort --key=2 -r -g
+ ./generate_report.pl report.raw.out | tee report.txt
clean::
rm -f report.raw.out report.txt
Index: llvm/test/Programs/generate_report.pl
diff -u llvm/test/Programs/generate_report.pl:1.2 llvm/test/Programs/generate_report.pl:1.3
--- llvm/test/Programs/generate_report.pl:1.2 Fri Jan 17 14:09:44 2003
+++ llvm/test/Programs/generate_report.pl Fri Jan 17 16:16:41 2003
@@ -34,83 +34,143 @@
# first test.
shift @Records;
-
-# Output the headers for the report....
-printf("%-20s ", "Name:");
-if ($SHOW_TIMES) {
- printf("%6s %-6s %-6s %-6s %-8s ",
- "Anlyz:", "LocTm:", "BUTim:", "TDTim:", "TimeSum:");
+# The column to sort by, to be overridden as neccesary by the report description
+my $SortCol = 2;
+my $SortReverse = 1;
+
+sub SumCols {
+ my ($Cols, $Col, $NumRows) = @_;
+ $Val = 0;
+ while ($NumRows) {
+ $Col--; $NumRows--;
+ $Val += $Cols->[$Col] if ($Cols->[$Col] ne "*");
+ }
+ return $Val;
}
-printf("%-8s %-8s %-8s %-8s ",
- "LocSize:", "BUSize:", "TDSize:", "BUTDSz:");
-printf("%-8s %-10s %-6s %-6s %-6s " . "| %-5s %-5s %-5s %-5s %-5s %-5s" .
- " | %7s %9s %5s\n",
- "NumFold", "NumNodes", "MaxSz", "GlobGr", "MaxSCC",
- "Loads", "Store", "Calls", "Allca", "Mallc", "Sum",
- "num/ind", "indcallee", "ratio");
+sub Ratio {
+ my ($Cols, $Col) = @_;
+ if ($Cols->[$Col-2] ne "*" and
+ $Cols->[$Col-2] != "0") {
+ return $Cols->[$Col-1]/$Cols->[$Col-2];
+ } else {
+ return "n/a";
+ }
+}
+my @Fields = (
+# Name
+ ["Name:" , '\'([^\']+)\' Program'],
+ [],
+# Times
+ ["Anlyz:", '([0-9.]+) \([^)]+\)[ 0-9]+TOTAL'],
+ ["LocTm:", '([0-9.]+) \([^)]+\)[ 0-9]+Local'],
+ ["BUTim:", '([0-9.]+) \([^)]+\)[ 0-9]+Bottom'],
+ ["TDTim:", '([0-9.]+) \([^)]+\)[ 0-9]+Top'],
+ ["SumTm:", sub { return SumCols(@_, 3); }],
+ [],
+# Sizes
+ ["LocSize:", '([0-9]+) Local'],
+ ["BUSize:" , '([0-9]+) Bottom-up'],
+ ["TDSize:" , '([0-9]+) Top-down'],
+ ["BU+TDSz:", sub { return SumCols(@_, 3); }],
+ [],
+# Misc stuff
+ ["NumFold" , '([0-9]+).*Number of folded nodes '],
+ ["NumNodes", 'Graphs contain \\[([0-9+]+)\\] nodes total'],
+ ["MaxSz" , '([0-9]+).*Maximum graph size'],
+ ["GlobGr" , '\\.GlobalsGraph\\.dot\'... \\[([0-9+]+)\\]'],
+ ["MaxSCC" , '([0-9]+).*Maximum SCC Size in Call Graph'],
+ [],
+ ["Loads" , '([0-9]+).*Number of Load insts'],
+ ["Store" , '([0-9]+).*Number of Store insts'],
+ ["Calls" , '([0-9]+).*Number of Call insts'],
+ ["Allca" , '([0-9]+).*Number of Alloca insts'],
+ ["Mallc" , '([0-9]+).*Number of Malloc insts'],
+ [" Sum " , sub { return SumCols(@_, 5); }],
+ #[" Sum " , sub { return $_[0]->[$_[1]-1]; }],
+ [],
+ ["num/ind" , '([0-9]+).*number of indirect call sites'],
+ ["indcallee",'([0-9]+).*number of callee functions at'],
+ ["ratio" , \&Ratio], # B / A if A != 0 else "n/a"
+ []
+ );
+
+my @Values;
+
+#
+# Read data into the table of values...
+#
foreach $Record (@Records) {
- # Print BM name
- printField('\'([^\']+)\' Program', $Record, -20);
+ my @RowValues;
+ my $Col = 0;
+ for $Row (@Fields) {
+ if (scalar(@$Row)) { # An actual value to read?
+ if (ref ($Row->[1])) { # Code to be executed?
+ push @RowValues, &{$Row->[1]}(\@RowValues, $Col);
+ } else { # Field to be read...
+ $Record =~ m/$Row->[1]/;
+ if (!defined($1)) {
+ push @RowValues, "*";
+ } else {
+ push @RowValues, $1;
+ }
+ }
+ } else { # Just add a seperator...
+ push @RowValues, "|";
+ }
+ $Col++;
+ }
+ my $Assert = "";
if ($Record =~ m/Assertion/) {
# If an assertion failure occured, print it out.
- print (grep /Assertion/, (split "\n", $Record));
- } else {
- if ($SHOW_TIMES) {
- # Print Times
- my $B = printField('([0-9.]+) \([^)]+\)[ 0-9]+Bottom', $Record, -6);
- my $L = printField('([0-9.]+) \([^)]+\)[ 0-9]+Local' , $Record, -6);
- printField('([0-9.]+) \([^)]+\)[ 0-9]+Bottom', $Record, -6);
- my $T = printField('([0-9.]+) \([^)]+\)[ 0-9]+Top' , $Record, -6);
- printf("%-8s ", $L+$B+$T);
- print "| ";
- }
+ $Assert = sprintf "\n\t\t\t%s", (grep /Assertion/, (split "\n", $Record));
+ }
+ push @RowValues, $Assert;
+ push @Values, [@RowValues];
+}
- # Print Sizes
- printField("([0-9]+) Local", $Record, -8);
- my $B = printField("([0-9]+) Bottom-up", $Record, -8);
- my $T = printField("([0-9]+) Top-down", $Record, -8);
- printf("%-8s ", $B+$T);
-
- print "| ";
- printField("([0-9]+).*Number of folded nodes ", $Record, -5);
- printField("Graphs contain \\[([0-9+]+)\\] nodes total", $Record, -10);
- printField("([0-9]+).*Maximum graph size", $Record, -6);
- printField("\\.GlobalsGraph\\.dot'... \\[([0-9+]+)\\]", $Record, -6);
- printField("([0-9]+).*Maximum SCC Size in Call Graph", $Record, -6);
-
- print "| ";
- my $I = printField("([0-9]+).*Number of Load insts", $Record, -5);
- $I += printField("([0-9]+).*Number of Store insts", $Record, -5);
- $I += printField("([0-9]+).*Number of Call insts", $Record, -5);
- $I += printField("([0-9]+).*Number of Alloca insts", $Record, -5);
- $I += printField("([0-9]+).*Number of Malloc insts", $Record, -5);
- printf("%-5s ", $I);
-
- print "| ";
- my $NI = printField("([0-9]+).*number of indirect call sites", $Record, -7);
- my $NC = printField("([0-9]+).*number of callee functions at", $Record, -9);
- if ($NI != 0) {
- printf("%-5s ", $NC/$NI);
- } else {
- printf("%-5s ", "n/a");
- }
+#
+# Sort table now...
+#
+ at Values = sort { $a->[$SortCol] cmp $b->[$SortCol] } @Values;
+ at Values = reverse @Values if ($SortReverse);
+
+#
+# Add the header for the report to the table after sorting...
+#
+my @Header;
+for $Row (@Fields) {
+ if (scalar(@$Row)) { # Non-empty row?
+ push @Header, $Row->[0];
+ } else { # Empty row, just add seperator
+ push @Header, "|";
+ }
+}
+unshift @Values, [@Header];
+#
+# Figure out how wide each field should be...
+#
+my @FieldWidths = (0) x scalar(@Fields);
+foreach $Value (@Values) {
+ for ($i = 0; $i < @$Value-1; $i++) {
+ if (length($$Value[$i]) > $FieldWidths[$i]) {
+ $FieldWidths[$i] = length($$Value[$i])
+ }
}
- print "\n";
}
-sub printField {
- ($Regex, $Record, $FieldWidth) = @_;
- #print "Args: '$Regex' '$Record'\n";
- $Record =~ m/$Regex/;
- if (!defined($1)) {
- printf("%${FieldWidth}s ", "*");
- return "0";
- } else {
- printf("%${FieldWidth}s ", $1);
+
+#
+# Print out the table now...
+#
+foreach $Value (@Values) {
+ for ($i = 0; $i < @$Value-1; $i++) {
+ printf "%-$FieldWidths[$i]s ", $$Value[$i];
}
- return $1;
+
+ # Print the assertion message if existant...
+ print "$$Value[@$Value-1]\n";
}
More information about the llvm-commits
mailing list