Re:Go vs. C++ – Which is faster?
by Someone on Sunday May 24, 2020 @03:52PM
(#23294185)
Likely explanation: using a byte for every flag takes a bit less CPU than packing 8 flags in a byte, but once the array outgrows the CPU’s cache, cache misses dominate running time.
Prediction: use std::bitset instead of an array of bool in the C++ code, and performance of the two programs will be (almost) identical.
Prediction: use std::bitset instead of an array of bool in the C++ code, and performance of the two programs will be (almost) identical.
I have a 2.3 GHz Intel Core i5 MacBook Pro, which is slower than the given hardware. The linked-to page reports "0.05s user".
I can reproduce that using g++ 9.1.0 using the default optimizations:
If I recompile with -O3, the result is significantly faster: