Profiling parsers written using parser combinator libraries in Haskell

328 views Asked by At

What are the standard methods to profile parser written in parser combinator libraries in Haskell?

I'm currently using uu-parsinglib but I would be very interested in knowing the methods of profiling also other parser combinator libraries like Parsec.

Right now I have written my parser and it is slow and eats a lot of ram (for 600 lines input text it takes about 5 seconds to parse with more than 1Gb of RAM and I want to investigate how I can improve it)

1

There are 1 answers

0
jev On

Try heap profiling:

$ ./prog +RTS -K128M -hc -p 
$ hp2ps -c prog.hp

If the profile looks like a mountain and is in the megabytes, probably you construct a large data structure first and then reduce it (and then could look into using accumulators or memoization).

More detailed info: http://book.realworldhaskell.org/read/profiling-and-optimization.html