How to profile long compile-times?

When writing macros or other code that does something at compile-time, it certainly sometimes happens that compile times suddenly increase drastically.

What tools and approaches are there available to profile or otherwise debug long compile-times?
For instance, it would be nice to use profiling tools like cprof/eprof/fprof but is it even possible to set them up in a way where they track compilation?

I wrote about general debugging here: How to debug Elixir/Erlang compiler performance - Dashbit Blog

For profiling, using profile.cprof/eprof/fprof and friends should include the compilation time of any module that you define in the file being tracked. Perhaps you can also emulate some stuff using Macro.expand(...).

3 Likes