[Haskell-cafe] Text.PrettyPrint.HughesPJ is sloooow (and wl-pprint-text is fast)

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Mon Feb 4 14:36:53 CET 2013


I was running into serious performance problems when printing moderately sized
Doc and Xml data (HaXml goes via Doc).

So I replace Text.PrettyPrint.HughesPJ with Text.PrettyPrint.Leijen.Text,
and patched the HaXml printer in the same way. Now it is running much faster.

This confirms some of the comments here:
http://stackoverflow.com/questions/9761507/which-pretty-print-library

If you want to see for yourself, here is a test case.
It constructs and prints a document tree with about 10^4 nodes,
rendered to an Xml document with 10^6 (nonblank) chars:
https://github.com/jwaldmann/haskell-tpdb/blob/master/test/speed.hs

Of the 4 output methods (fin the main program), only one takes < 1 second.
Rendering via HughesPJ needs extra stack (!) and takes about 20 seconds.
Rendering via Text.XML.HaXml.ByteStringPP seems much slower still (!)

(ghc-7.6.2, pretty-1.1.1.0, HaXml-1.23.3, wl-pprint-text-1.1.0.0,
amd64, fedora 18, kernel 3.7.4)





More information about the Haskell-Cafe mailing list