This is extension of this question. I am using rust for these benchmarks. Performance of 64bits multiplication is equal to 32bit multiplication. IN previous question people suggested to use benchmarking and after using that I am still getting same performance. Please note I am new with rust so please let me know if I am doing anything wrong. Here is my simple bench marking file
use criterion::{black_box, criterion_group, criterion_main, Criterion};
pub fn test_64_mul(test_num: u64){
for _ in 1..20000{
let mut _prod = test_num as u128 * test_num as u128;
}
}
pub fn test_32_mul(test_num: u32){
for _ in 1..20000{
let mut _prod = test_num as u64 * test_num as u64;
}
}
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("mul 64", |b| b.iter(|| test_64_mul(black_box(12345678653435363454))));
c.bench_function("mul 32", |b| b.iter(|| test_64_mul(black_box(1234565755))));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
Now when I do cargo bench
output is:
mul 64 time: [312.47 ps 312.66 ps 312.93 ps]
mul 32 time: [312.56 ps 312.75 ps 312.99 ps]