4 ms·
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 i
by teoryn 12y ago
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.
- jasondavies 12y agoIt'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. [0]: http://doc.rust-lang.org/test/fn.black_box.html http://doc.rust-lang.org/test/fn.black_box.html
- bilalhusain 12y agoBut it appears that the Rust code is avoiding optimization over f() whereas for C code `asm("");` is inside iteration loop.