What's the reason for 'asm("");' in 002.c (and other c codes)? All I can see that doing is intentionally breaking the compiler's ability to optimize over loop iterations, which puts rust a huge advantage over c.
It's probably to avoid dead-code elimination, which would defeat the purpose of the benchmark. The rust benchmarks use test::black_box [0], which does the same thing, so there's no unfair advantage there.
For this particular benchmark Rust is beating C and LuaJIT by an unbelievable margin. I emitted IR for the Rust code[1] and it contains 4613732, the result of function f.
This is one of the reasons microbenchmarks are really not particularly useful, especially when comparing two different languages. You have to intentionally cripple the optimizer in order to even get some of them to run the "actual" algorithm. And you have to restrict the algorithm used even if it might be impossible to implement the fastest algorithm as efficiently in one or more of the languages. You might argue that the point isn't to test the particular code, but the properties of the language and its optimizer. That's fair, but what about languages like Go that don't try to do constant folding like this in the name of fast compilation, or interpreted languages that don't perform JIT compilation? They are going to look unrealistically good on benchmarks like this compared to how similar routines would perform in an actual program.