aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-02-26 23:52:28 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-02-26 23:52:28 -0800
commite798db14e87fd4bbb5c0068fb5052ba3e5f92d4b (patch)
tree13fd69bef078caf3289208e38f2267214da8f820 /tools
parentc072b7cb5978c35493cfe14e55e9d214b4f7f042 (diff)
downloadpandoc-e798db14e87fd4bbb5c0068fb5052ba3e5f92d4b.tar.gz
Add tools/parseTimings.pl.
A script to help pin down which modules take the most time and memory to compile.
Diffstat (limited to 'tools')
-rw-r--r--tools/parseTimings.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/parseTimings.pl b/tools/parseTimings.pl
new file mode 100644
index 000000000..aa12bfabb
--- /dev/null
+++ b/tools/parseTimings.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+
+# Breaks down compilation time and memory usage by module.
+# To use this script, do
+#
+# stack clean
+# stack build --ghc-options='-dshow-passes' 2>output.txt
+# perl parseTimings.pl output.txt
+
+while (<>) {
+ if (/!!! (.*) \[(.*)\]: finished in (.*) milliseconds, allocated (.*) megabytes/) {
+ $phase = $1;
+ $module = $2;
+ $milliseconds = $3;
+ $megabytes = $4;
+ if (!$timings{$module}) {
+ $timings{$module} = {'milliseconds' => 0, 'megabytes' => 0};
+ };
+ $timings{$module}{'milliseconds'} += $milliseconds;
+ $timings{$module}{'megabytes'} += $megabytes;
+ }
+ }
+ printf("%10s %10s %s\n", "Time (ms)", "Alloc (Mb)", "LOC", "Module");
+ for (keys %timings) {
+ $path = $_;
+ $path =~ s/\./\//g;
+ $path = "src/$path.hs";
+ $loc = `wc -l $path 2>/dev/null`;
+ if ($loc) {
+ $loc =~ s/^\s*(\d+).*/\1/;
+ printf("%10d %10d %6d %s\n", $timings{$_}{'milliseconds'}, $timings{$_}{'megabytes'}, $loc, $_);
+ }
+}