Help comparing Rust vs Julia speed

A small change that really ought not to matter, but sometimes does:

-pub fn npv(mortality_rates: &Vec<f64>, lapse_rates: &Vec<f64>, interest_rate: f64, sum_assured: f64, premium: f64, init_pols: f64, term: Option<usize>) -> f64 {
+pub fn npv(mortality_rates: &[f64], lapse_rates: &[f64], interest_rate: f64, sum_assured: f64, premium: f64, init_pols: f64, term: Option<usize>) -> f64 {

And even if it doesn't improve speed, it's better style -- it's more general as it allows passing subslices instead of requiring full vectors, without really any cost (not even syntax at the call site, as &Vec<T> will deref-coerce to &[T] automatically).

Can you share how you got the measurement you did? Anything below about 16ms is extremely sensitive to external stuff, and thus rather hard to benchmark reliably. Obligatory mention of Criterion.rs - Criterion.rs Documentation

6 Likes