foobarF
Deno12mo ago
1 reply
foobar

wasmbuild / speed rust crate vs native deno

I have coded an PV & XIRR function, one in rust linked to deno with wasmbuild, another in deno

I benchmark the result and I was quite surprise that deno was better than Rust.

Could someone explain those results ?

Is it the conversion of date between deno and rust that drags the performance ?

In general, will using rust function be faster than deno function ?

  let mut dates_like: Vec<DateLike> = vec![];
  for item in dates.iter() {
    let d = js_sys::Date::from(item);
    dates_like.push(DateLike::from(d))
  }


benchmark   time/iter (avg)        iter/s      (min … max)           p75      p99     p995
----------- ----------------------------- --------------------- --------------------------
Deno PV              4.0 ns   250,800,000 (  4.0 ns …   9.2 ns)   4.0 ns   4.3 ns   4.6 ns
Rust PV             43.2 ns    23,140,000 ( 42.9 ns …  59.7 ns)  43.2 ns  48.0 ns  50.7 ns
Deno XIRR            3.6 ms         274.4 (  3.6 ms …   4.1 ms)   3.7 ms   3.8 ms   4.1 ms
Rust XIRR          132.1 ms           7.6 (131.7 ms … 132.8 ms) 132.3 ms 132.8 ms 132.8 ms
Was this page helpful?