On 08.02.2013 23:26, Nicolas Bock wrote:General performance hints
Hi list,
I wrote a script that reads matrix elements from standard input, parses
the input using a regular expression, and then bins the matrix elements
by magnitude. I wrote the same script in python (just to be sure :) )
and find that the python version vastly outperforms the Haskell script.
1) Strings are slow. Fast alternatives are text[1] for textual data and bytestrings[2] for binary data. I can't say anything about performance of Text.Regex.Posix.
2) Appending list wrong operation to do in performance sensitive code.
(++) traverses its first argument so it's O(n) in its length.
What exactly are you tryeing to do? Create a histogram?If you want performance you absolutely should use -O2.
The Haskell script was compiled with "ghc --make printMatrixDecay.hs".
[1] http://hackage.haskell.org/package/text
[2] http://hackage.haskell.org/package/bytestring
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe