3 ms·
for (; counter < 1_000; counter++) { // ... I know this doesn't make much sense :) } I think the JVM would optimise away this loop because it doesn
by ahpeeyem 4y ago
for (; counter < 1_000; counter++) {
// ... I know this doesn't make much sense :)
}
I think the JVM would optimise away this loop because it doesn't do anything. e.g. if the loop optimisation method is to unroll the loop into 1000 inline statements, there's nothing there.
This makes "No Logging" result not quite a fair comparison; maybe something like the sum of 1000 random numbers do some actual work in the loop.
- invalidname 4y agoExactly my thoughts when reading the article. A bad micro-benchmark that puts everything in bad context as a result. I have numbers on the impact of logging from other articles that show a significant impact, but nothing at this scale.
- j16sdiz 4y agoIn many C/C++ optimizing compiler, this is replaced with `counter = 1000;`. I have no idea how java handle this.. Does the AOT compiler do any optimization? Would this defer to the JIT?
- thfuran 4y agoThere is aot native compilation in javaland these days, but I assume you mean javac, the compiler that transforms source into jvm bytecode. It defers pretty much all optimization to the JITs and won't remove empty loops.
- pwagland 4y agoNo, but in this case, the JIT will get rid of this empty loop.