A file reading benchmark
bearophile
bearophileHUGS at lycos.com
Fri Feb 17 19:25:05 PST 2012
Walter Bright:
> If you're going to benchmark reading a file line by line, that's what your code
> should do. But that isn't what it does, it conflates it with appending to an array.
I have used the benchmark presented on Reddit.
I understand that a read-only benchmark is more useful for D developers. Removing the storing of lines the code is slower than equivalent Python code still.
----------------
>Bearophile, when comparing a deque to a classic vector, of course the deque is going to win. This has nothing to do with D, and everything to do with writing a good algorithm.<
In this specific case you are wrong: in Python if I replace the deque with a list (that is a dynamic array), the runtime grows only by less than 0.2 seconds. I know this benchmark is about Phobos not about D.
> Also, Appender has known performance problems with large appends (Issue 5813 http://d.puremagic.com/issues/show_bug.cgi?id=5813 , I'm currently folding in Vladimir's suggestions and generating a pull request)<
OK. We'll see. But the File.byLine() is slower than file by line reading, regardless appending to deques of arrays or appenders.
Bye,
bearophile
More information about the Digitalmars-d
mailing list