https://github.com/shubham0204/wasm-js-algorithms
Implementation of various algorithms in WebAssembly and vanilla Javascript
https://github.com/shubham0204/wasm-js-algorithms
Last synced: 7 months ago
JSON representation
Implementation of various algorithms in WebAssembly and vanilla Javascript
- Host: GitHub
- URL: https://github.com/shubham0204/wasm-js-algorithms
- Owner: shubham0204
- License: apache-2.0
- Created: 2024-04-28T03:22:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-03T03:31:33.000Z (over 1 year ago)
- Last Synced: 2025-01-23T13:43:54.067Z (9 months ago)
- Language: JavaScript
- Homepage: https://shubham0204.github.io/WASM-JS-Algorithms/
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Implementation of Algorithms in WebAssembly and Javascript
## Problems / Algorithms
* [Insertion Sort](https://shubham0204.github.io/WASM-JS-Algorithms/pages/insertion_sort/index.html)
* [Finding Prime Factors (Brute-force)](https://shubham0204.github.io/WASM-JS-Algorithms/pages/prime_factors/index.html)## Goals
* Demonstrate the use of WebAssembly modules, compiled from Rust, in a simple HTML + JS webpage
* Compare the execution time of WASM and plain JS implementations
* Explore [`wasm-bindgen`](https://rustwasm.github.io/wasm-bindgen/introduction.html) and [`js-sys`](https://crates.io/crates/js-sys) crates for Rust-WASM compilation## Setup
1. Install [Rust](https://www.rust-lang.org/tools/install) and `wasm32-unknown-unknown` toolchain with `rustup`.
```
$> rustup target add wasm32-unknown-unknown
```2. Clone the repository and compile the target which results in a `algo.wasm` module in
`target/wasm32-unknown-unknown/release`,```
$> git clone https://github.com/shubham0204/WASM-JS-Algorithms
$> cd WASM-JS-Algorithms
$> cargo build --release --target=wasm32-unknown-unknown
```3. Install `wasm-bindgen-cli` and use it to produce Javascript glue code
for `algo.wasm` in the `web` directory.```
$> cargo install wasm-bindgen-cli
$> wasm-bindgen --out-dir web --target web --no-typescript target/wasm32-unknown-unknown/release/algos.wasm
```