WordCount performance
bearophile
bearophileHUGS at lycos.com
Thu Mar 27 16:34:30 PDT 2008
Walter Bright:
> gcc may not synchronize stdin for multiple threads, or may have found a
> way to avoid the locking if the start-new-thread function in the library
> is never called.
Thank you taking a look at this benchmark. I understand that D is safer regarding non-ASCII, but 8 times slower seems a lot.
I think GCC has functions like fgets_unlocked, getc_unlocked, etc, (that I think DMD std lib misses) for single thread programs:
http://linux.die.net/man/3/fgets_unlocked
http://www.opengroup.org/onlinepubs/009695399/functions/getc_unlocked.html
>For the Digital Mars stdio library, the way to do fast I/O from the synchronized streams is to do it in chunks, not character-by-character. Several functions in std.stdio are available to do this - I bet you'll get a dramatic speed boost by using one of them.<
At the moment DMD is two times slower than Clean in number reading benchmark, so there's space for improvements there too:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all
http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all
Bye, and thank you,
bearophile
More information about the Digitalmars-d
mailing list