3 ms·
The Clang result is suspiciously fast. Way faster than GCC and my Java attempt. Maybe its dead code pruning the string conversion? Java was about the same as J
by eggsnbacon1 6y ago
The Clang result is suspiciously fast. Way faster than GCC and my Java attempt. Maybe its dead code pruning the string conversion?
Java was about the same as Julia for this, on my machine
- runevault 6y agoIf it's using string optimizations due to short strings, you're cutting allocations in almost half I believe, as well as putting said strings on the stack instead of the heap which will give... significant performance gains. Short strings in the C++ standard library can be crazy fast.
- plorkyeran 6y agoIt doesn't merely cut allocations in half; it cuts them to zero.
- runevault 6y agoDo you mean allocations as in heap? If so yeah, I guess I should have stated it better as it still needs to put space on the stack for the short string.
- josefx 6y agoThe stack space for the whole function call is allocated in one step. You only get individual allocations when you are messing around with variable length arrays or alloca.
- pjmlp 6y agoFor Java did you try a second run using CDS and PGO data?
- eggsnbacon1 6y agoI ran mine in JMH which does a bunch of warmup iterations, hopefully enough to trigger full JIT