I added some optimizations to the Rust compiler on my branch, added inlining attributes to match the C version, removed I/O (we have performance problems there that are under active development) and reduced the integer sizes to 32 bit to match the C version more closely (see [1]) and got the time down to within 50%:
C version: 0m1.305s
Rust version: 0m1.871s
I think the remaining time may be attributed to the fact that you used smaller integer widths for the various internal arrays in the C version and larger integer widths in the Rust version. Remember that Rust `int` types are the size of a register (like Go 1.1), so they're 64 bit on x86-64. You can use `i8`, `i16`, etc. for smaller integer widths.
Bounds checks may also have some effect; we should add methods to allow them to be avoided.
Finally, thanks for trying out Rust. Do you mind if we add this benchmark to our test suite?
Edit: Updated the gist to use smaller integer widths, like the C version. Now Rust is within 33% of the C version:
C version: 0m1.305s
Rust version: 0m1.871s
I think the remaining time may be attributed to the fact that you used smaller integer widths for the various internal arrays in the C version and larger integer widths in the Rust version. Remember that Rust `int` types are the size of a register (like Go 1.1), so they're 64 bit on x86-64. You can use `i8`, `i16`, etc. for smaller integer widths.
Bounds checks may also have some effect; we should add methods to allow them to be avoided.
Finally, thanks for trying out Rust. Do you mind if we add this benchmark to our test suite?
Edit: Updated the gist to use smaller integer widths, like the C version. Now Rust is within 33% of the C version:
C version: 0m1.205s
Rust version: 0m1.613s
[1]: https://gist.github.com/pcwalton/5327090