Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.

[0]: http://doc.rust-lang.org/test/fn.black_box.html


But it appears that the Rust code is avoiding optimization over f() whereas for C code `asm("");` is inside iteration loop.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: