3 ms·
Benchmark is rubbish. The Nim version is using a standard nim 'table' for the bracket_map, which is a hash table. The C++ version is using std::map which is a r
by nly 11y ago
Benchmark is rubbish. The Nim version is using a standard nim 'table' for the bracket_map, which is a hash table. The C++ version is using std::map which is a red-black tree.
A quick once-over with gprof shows the C++ interpreter running bench.b shows it is spending 30% of its time allocating rb-tree nodes and another 30% searching it.
Swapping it out for a unordered_map (a hash table) actually makes it slower, but ~40% of the runtime is then sunk in to inserting in to the hash table. Probably allocating
I couldn't be bothered to drill in any further.
- srean 11y agoJust so that you know neither the Felix author nor me are involved in the benchmark. More tellingly the benchmarked codes were user contributed. Regardless I did not get your point, just in case you had any. Different implementations used their idiomatic data structures and got what they got. You ranted about the choice and tried an alternative and it turned out to be slower and dismissed it entirely saying none of this is worth your time. And you said all these because ...? There is probably a reason and an underlying conclusion you wanted to convey, but frankly it escapes me so I couldn't be bothered with following up further on a middle brow dismissal either.