This contains the Rust code that powers Quadratic's client via WASM.
Documentation for formula functions can be found in next to the Rust implementation of each function, in src/formulas/functions/*.rs
. (mod.rs
and util.rs
do not contain any functions.)
Run cargo run --bin docgen
, then copy/paste from formula_docs_output.md
into Notion. Copying from VSCode will include formatting, so you may have to first paste it into a plaintext editor like Notepad, then copy/paste from there into Notion.
Code coverage tooling has been added to the npm scripts. Before running, install dependencies:
cargo install grcov
rustup component add llvm-tools-preview
To generate the LLVM profraw files, run the following from the root:
npm run coverage:wasm:gen
Once the profraw files are generated, you can generate and view HTML by running the following from the root:
npm run coverage:wasm:html
npm run coverage:wasm:view
To run benchmarks in pure compiled Rust, run cargo bench
rustup target add wasm32-wasi
cargo install cargo-wasi
cargo wasi build --bench=grid_benchmark --release --no-default-features
cp target/wasm32-wasi/release/deps/grid_benchmark-*.wasm .
ls
- There should be three WASM files (perhaps more if you have done prior builds). Ignore the ones with
.rustc.wasm
and.wasi.wasm
. Rename the remaining.wasm
file tobenchmark.wasm
.
We include --no-default-features
specifically to disable the js
feature of quadratic-core
, because the benchmark suite uses only WASI APIs and cannot depend on JS.
To run in NodeJS:
npm install -g @wasmer/cli
wasmer-js run --dir=. benchmark.wasm -- --bench
To run in browser:
- Go to https://webassembly.sh/
- Drag
benchmark.wasm
into the browser window - In the browser,
benchmark --bench | download