3 ms·
I replaced the array/"surrounding" list with an unboxed vector, and removed the strictness annotations and it runs at ~0.85 on my machine, while the C code runs
by mej10 14y ago
I replaced the array/"surrounding" list with an unboxed vector, and removed the strictness annotations and it runs at ~0.85 on my machine, while the C code runs at around ~0.5.
The code is so incredibly close to your SML code (where you also spell out that you are using the Vector type). I am just blown away by how matter of fact you were in your statement.
Please either change your benchmark to use the same data type as all of the other examples, or stop using it as an example of Haskell's performance.
- postfuturist 14y agopull request? I'm no Haskell expert (which apparently you need to be to get decent performance.)
- mej10 14y agoMy point is, I am not Haskell expert, but I know that linked lists aren't an efficient data structure for what we're doing. You didn't use lists in your other implementations, so it was just weird that you did for Haskell (originally, and then sort of again for life-array.hs). For your life-array.hs implementation, you replaced the Grid with an array, but not the "surroundings" with one, even though you used Vector for both in your SML implementation. Built with -O2 option: https://gist.github.com/3189306 https://gist.github.com/3189306 Sorry if I came off a bit assholish. People have been saying that you need to be a Haskell expert to get good performance forever, and in my experience this just isn't true. I will admit that there is clearly a problem with how things are introduced, as it is common that new Haskellers think they can use lists for every thing. I am sure part of the problem is that this is one of the few data structures available from the Prelude.
- postfuturist 14y agoNo sweat, thanks for the gist, I'll add it the repo. I'm impressed, actually, if it brings the runtime under a second, because only a couple languages managed that. The act of finding the correct strictness hints seems a bit like black magic.
- mej10 14y agoThats part of the nice thing about the code I sent you - no strictness hints.