Skip to content

suelopoder/rust-wasm-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What

This app is a simple test for Rust on the web via WASM. I test a simple sort of a big array in plain JS and in a compiled rust lib. Then I tried both again but loaded from a web worker.

Chrome timing console output Chrome performance recording

Performance results

As expected Rust beats JS sorting a JS array for big arrays. It's worth noting that both block the main thread. The workaround is to sort within a web worker, with similar timings but not blocking. Results

Demo

How

Run wasm-pack build --target no-modules to build the JS glue code. Then open index.html in a browser.

Unit test

To test rust code run: wasm-pack test --node

Why

Test rust and JS interactions and wrap my head around when it would be a good idea to use it.

Resources

Next steps

I wonder if we could return a promise in Rust that will execute in background. This shouldn't improve performance though.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published