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()
.
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.
We see par_iter
winning, as expected:
We see that iter()
and par_iter()
performs almost exactly the same, with a very minimal overhead cost for par_iter()
:
cargo run --release
- Install Trunk with
cargo install --locked trunk
. - Run
trunk serve --release
to build and serve onhttp://127.0.0.1:8080
. Trunk will rebuild automatically if you edit the project. - Open
http://127.0.0.1:8080/index.html#dev
in a browser. See the warning below.