Skip to content

maxinteger/mandelbrot-wams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot set with WASM

Experimental project to test WASM and WebWorkers https://mandelbrot-wasm.web.app/

Install

    npm install

For rust, make sure you installed Rust lang, then run:

    cargo install wasm-pack
    cargo install wasm-snip

Run locally

    npm run server

then open http://127.0.0.1:8080

Build all render engines

    npm run build

Render engines

Native JS

The baseline implementation of the Mandelbrot set rendering

Native WASM

WASM has human readable text format, the file extension is usually wat. This format must be transformed into binary WASM

AssemblyScript -> WASM

AssemblyScript is a TypeScript like language what we can compile to WASM

Rust -> WASM

Rust is a modern system language (like C, C++). With wasm-pack we can compile rust code to WASM

Limitations / bugs

  • The app works only in chromium based browsers right now

Other

More link

Takeaways:

  • WASM average execution time is a little slower then native JS (with the current implementation of WASM + Mandelbrot is very specific problem the engine can optimise JS very well)
  • Naive hand written WASM can not beat the compiled and optimized code
  • WASM not start new thread, you have to run it in webWorker for that.