Profiling Haskell programs
A quick 101 on profiling Haskell programs
Benchmark functions, note that you have to be mindful of laziness, otherwise you might not force a result out of the function.
Profile runtime heap allocation
Profile runtime costs of each function. Note ordering might be ambiguous at times, although mostly accurate. I encountered issues when dealing with Lazy IO.
Single file just use ghc profiling flags.
For heap profiling, i.e. via threadscope, make sure to add
-eventlog when compiling and
+RTS -l rts option during runtime.
You can specify these in cabal file if you’re using cabal / stack.
Read the ghc profiling guide.
Small PoCs to understand behaviour before benchmarking the entire app.