Analyze GHC .dump-timings files
Go to file
2024-02-02 22:16:00 -08:00
.github/workflows Try adding CI 2024-02-02 22:16:00 -08:00
dist Rebuild without test data baked in 2021-08-02 12:22:11 -07:00
scripts Parse systool events, closes #2 2021-08-02 10:42:51 -07:00
src Working on treemap 2024-02-02 22:04:00 -08:00
.gitignore Switch to a different starter 2021-07-31 19:05:03 -07:00
default.nix Update nix dependencies 2021-08-02 11:00:05 -07:00
hledger.png Add instructions and another image 2021-08-01 04:04:24 -07:00
hledger.svg Add README + image 2021-08-01 03:55:45 -07:00
LICENSE Create LICENSE 2021-10-08 18:27:13 -06:00
package-lock.json Bump package-lock.json to lockfile version 3 2024-02-02 21:21:52 -08:00
package.json Get rid of old node thing 2021-08-01 01:11:32 -07:00
pinned-nixpkgs.nix Add nix derivation 2021-08-01 02:54:54 -07:00
README.md Update README.md: use shell for code blocks 2024-02-01 17:38:25 -08:00
time-ghc-modules Make configurable PROCESS_SCRIPT and HTML_FILE env variables 2021-10-07 23:20:13 -06:00
time-ghc-modules-nix Update nix dependencies 2021-08-02 11:00:05 -07:00
tsconfig.json Missed Bars.tsx 2024-02-02 21:45:52 -08:00

time-ghc-modules

Figure out why your builds are slow. This tool analyzes how long it takes GHC to compile your Haskell modules, broken down by phase.

Quick start

cd <my-project>

stack clean
stack build --ghc-options "-ddump-to-file -ddump-timings"
# ----- OR -----
cabal clean
cabal build --ghc-options "-ddump-to-file -ddump-timings"

If you have Nix, you can simply run time-ghc-modules from Nixpkgs!

nix run nixpkgs#time-ghc-modules

Or, clone the repo first:

git clone git@github.com:codedownio/time-ghc-modules.git /path/to/time-ghc-modules

# If you have Nix, you can use the fully reproducible version
/path/to/time-ghc-modules/time-ghc-modules-nix

# Otherwise, your system needs to have SQLite >= 3.33.0, Python 3, and sed
/path/to/time-ghc-modules/time-ghc-modules

The script will search for all your *.dump-timings files and analyze them. It will finish by printing out the path to an HTML file:

...
--> Wrote report at file:///tmp/tmp.pvnp4FYmLa/report.html

Example: hledger

You can generate the time report below for hledger by running the following commands (assuming you have Nix).

set -e
cd $(mktemp -d)
git clone git@github.com:simonmichael/hledger.git
git clone git@github.com:codedownio/time-ghc-modules.git
cd hledger
stack build --ghc-options "-ddump-to-file -ddump-timings"
../time-ghc-modules/time-ghc-modules-nix

hledger profile

Tips

The script will output its log messages to stderr and print the final report path to stdout (assuming it didn't exit with a failure). This makes it easy to use the output in scripts. For example:

# Build the report and open it in your browser
> firefox $(/path/to/time-ghc-modules/time-ghc-modules)
# Build the report in CI and stash it somewhere
> cp $(/path/to/time-ghc-modules/time-ghc-modules) $MY_CI_ARTIFACTS_DIR/

Compatibility

The flag -ddump-timings is available for GHC >= 8.4.1.