emilk / rayon_test

Test the use of rayon on Wasm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rayon test

Testing this PR, that allows us to run rayon on Wasm without threads: rayon-rs/rayon#1019

We benchmark summing a Vec<u64> with a for-loop, with iter().sum() and with par_iter().sum().

Results

I wanted to see wether or not using par_iter() without any actual threading would add a lot of overhead.

Tested on an M1 MacBook Pro.

Native

We see par_iter winning, as expected:

image

Wasm in Firefox

We see that iter() and par_iter() performs almost exactly the same, with a very minimal overhead cost for par_iter():

image

Running it yourself

Natively

cargo run --release

Web

  1. Install Trunk with cargo install --locked trunk.
  2. Run trunk serve --release to build and serve on http://127.0.0.1:8080. Trunk will rebuild automatically if you edit the project.
  3. Open http://127.0.0.1:8080/index.html#dev in a browser. See the warning below.

About

Test the use of rayon on Wasm


Languages

Language:Rust 46.8%Language:HTML 43.6%Language:JavaScript 5.7%Language:Shell 4.0%