Is there a way to see the compile times of each module?

157 views Asked by At

I've searched the ghc user manual to the best of my ability, but I haven't been able to find a way to have ghc print the timings of each module as it is compiled.

1

There are 1 answers

1
K. A. Buhr On

I assume you've found -ddump-timings which dumps runtime in milliseconds by stage and module? I'm pretty sure your best bet will be to parse its output and sum the times by module.

Looking through the GHC source, the only one piece of code that calls getCPUTime is in file compiler/GHC/Utils/Error.hs, function withTiming', and this is the output that's enabled by -ddump-timings. While there could technically be some call to withTiming' that accounts for the total compilation time of a module, it strikes me as unlikely that it would be disabled by default, and a search for all occurrences of withTiming in the compiler code base doesn't turn up anything. So, the -ddump-timings output is probably the best you can do.