Bug 10667 – http://dlang.org/cppstrings.html benchmark example doesn't really show off slices
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-18T19:46:00Z
Last change time
2015-08-22T15:16:07Z
Assigned to
nobody
Creator
jlquinn
Comments
Comment #0 by jlquinn — 2013-07-18T19:46:29Z
While the wordcount benchmark programs do show what can be done with C++98 vs D2, this is not really a good demonstration of the performance benefits of slices.
The D program stores word counts in a hash map. The C++ version given uses a map, which is required to be a balanced binary tree data structure. For sizable input, the algorithmic advantage will swamp the savings from using slices.
This is also a small enough input that memory handling effects probably won't get noticed. I suspect the D program never needs to run a GC cleanup before the end.
I highly suggest the C++ programs be converted to C++11 where unordered_map is available to remove the hidden algorithmic advantage. Secondly, repeat the input a number of times so the timing is more meaningful.
Comment #1 by hsteoh — 2015-08-22T15:16:07Z
This page apparently is no longer included in the website build. Closing this for now. Please reopen if similar issues exist in currently-public website pages, thanks!