Test program for the "Learning Rust" tutorial by Leo Tindall on O'Reilly Learning.
I use this project to learn various Rust aspects:
- Modules
- Struct
- Random
- Vec allocation
- Rustdoc
Because of the experimental benchmark code
you must use the nightly version of the Cargo
toolchain.
cargo +nightly build
In order to benchmark the two merging functions run:
cargo +nightly bench
In my tests, the optimized parallel recursive is actually 3 to 30 times slower than the simple iterative version:
$ > cargo +nightly bench
Compiling rust-barycenter v0.1.0 (/Users/ffarid/src/RUST/rust-barycenter)
Finished bench [optimized] target(s) in 1.25s
Running target/release/deps/rust_barycenter-df6957fa89931341
running 4 tests
test tests::bench_merge_iterative_large ... bench: 6,134,557 ns/iter (+/- 1,874,839)
test tests::bench_merge_iterative_small ... bench: 5,378 ns/iter (+/- 214)
test tests::bench_merge_recursive_large ... bench: 18,598,300 ns/iter (+/- 10,618,726)
test tests::bench_merge_recursive_small ... bench: 165,415 ns/iter (+/- 78,220)
test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured; 0 filtered out
- Leo Tindall
- Farzad FARID
- "Learning Rust" tutorial: https://www.packtpub.com/eu/application-development/learning-rust-video
- "Learning Rust" source code: https://github.com/PacktPublishing/Learning-Rust-video