@@ -0,0 +1,33 @@
1+#!/usr/bin/env perl
2+
3+# Breaks down compilation time and memory usage by module.
4+# To use this script, do
5+#
6+# stack clean
7+# stack build --ghc-options='-dshow-passes' 2>output.txt
8+# perl parseTimings.pl output.txt
9+
10+while (<>) {
11+ if (/!!! (.*) \[(.*)\]: finished in (.*) milliseconds, allocated (.*) megabytes/) {
12+ $phase = $1;
13+ $module = $2;
14+ $milliseconds = $3;
15+ $megabytes = $4;
16+ if (!$timings{$module}) {
17+ $timings{$module} = {'milliseconds' => 0, 'megabytes' => 0};
18+ };
19+ $timings{$module}{'milliseconds'} += $milliseconds;
20+ $timings{$module}{'megabytes'} += $megabytes;
21+ }
22+ }
23+ printf("%10s %10s %s\n", "Time (ms)", "Alloc (Mb)", "LOC", "Module");
24+ for (keys %timings) {
25+ $path = $_;
26+ $path =~ s/\./\//g;
27+ $path = "src/$path.hs";
28+ $loc = `wc -l $path 2>/dev/null`;
29+ if ($loc) {
30+ $loc =~ s/^\s*(\d+).*/\1/;
31+ printf("%10d %10d %6d %s\n", $timings{$_}{'milliseconds'}, $timings{$_}{'megabytes'}, $loc, $_);
32+ }
33+}