From my experience this kind of number crunching is where you'll expose the worst Java/C# performance because each operation is tiny, meaning ANY overhead is quite significant. i.e. running a very tight loop with not much happening inside.
It is interesting that it doesn't optimise better, unless the underlying data structures/objects have extra safety-code running perhaps? I don't know what algorithms are used, I wouldn't bet C# and C++ use exactly the same for all collections/algorithms though. No doubt one can find out, though with STL it is implementation-specific IIRC.
It is interesting that it doesn't optimise better, unless the underlying data structures/objects have extra safety-code running perhaps? I don't know what algorithms are used, I wouldn't bet C# and C++ use exactly the same for all collections/algorithms though. No doubt one can find out, though with STL it is implementation-specific IIRC.

ure. I had a look at sorting small structures that contain a key & array index as I think that's more like something I would do, and disregarding setup, allocation, copying etc, just timing the call to the sort routines I got:

, I'm kind of suprised. I was expecting with all the improvements of JIT and modern processors to be getting about 10% at best with C++.
Comment