Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling Template Haskell

I have a TH-heavy file which takes around 30 seconds to compile. What are some techniques I can use to help debug the performance of my Template Haskell?

like image 674
James Koppel Avatar asked Aug 20 '13 09:08

James Koppel


1 Answers

If I understand compile flow of TH correctly, the ordinary haskell functions are being executed while splicing at compile time. But you can run then at the runtime on your own, of course.

For example you have something like $(foo x y ...) in your TH-heavy file. Create another file and call 'foo x y' there but don't splice the result. Then you'll be able to profile 'foo' as usual. If the bottleneck is at the AST generation stage you'll locate it. Don't forget to consider lazyness.

like image 111
user3974391 Avatar answered Nov 27 '22 04:11

user3974391