7 ms·
If you write C++ like it's Java, it will be slower, mostly for two reasons: - A C++ compiler cannot do speculative devirtualization. Which hurts if you split e
by tpolzer 6y ago
If you write C++ like it's Java, it will be slower, mostly for two reasons:
- A C++ compiler cannot do speculative devirtualization. Which hurts if you split everything into small virtual functions.
- If you are churning through lots of small allocations and aren't maxing all CPU cores, a garbage collector running in parallel is nearly free - unlike the bookkeeping your C++ deallocations have to go through.
- saagarjha 6y ago> A C++ compiler cannot do speculative devirtualization. Yes, it can! For example: https://godbolt.org/z/-JtSiJ https://godbolt.org/z/-JtSiJ