mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-15 09:40:52 +00:00
This commit starts to add a page of microbenchmarks for wasm-bindgen which we can hopefully track and compare over time. Right now it's primarily focused on data collection, making it easy to collect data across a number of benchmarks for comparison. It doesn't currently do much in the way of actually comparing the results for you (aka drawing pretty graphs), so let's left for a future step. It's hoped though that we can use this to track performance improvements as well as ensuring that they work over time!
55 lines
1.8 KiB
Markdown
55 lines
1.8 KiB
Markdown
# Microbenchmarks for `wasm-bindgen`
|
|
|
|
This folder houses a number of microbenchmarks for `wasm-bindgen`. These, like
|
|
all microbenchmarks, should be taken with a grain of salt. They are intended to
|
|
help developers understand changes over time, but they are not intended to be a
|
|
performance suite for WebAssembly for Rust.
|
|
|
|
[View benchmarks for `master` branch online][online]
|
|
|
|
[online]: https://rustwasm.github.io/wasm-bindgen/benchmarks/
|
|
|
|
## Building and Running
|
|
|
|
First, copy the benchmarks to a temporary directory:
|
|
|
|
```
|
|
$ cp ./benchmarks /some/other/directory
|
|
```
|
|
|
|
Next, `cd` into that directory and execute:
|
|
|
|
```
|
|
$ wasm-pack build --target web
|
|
```
|
|
|
|
Next, use your favorite static file server to host the current directory. For
|
|
example using the [`https` crate](https://crates.io/crates/https):
|
|
|
|
```
|
|
$ http
|
|
```
|
|
|
|
Then open up a web browser and view http://localhost:8000, for example.
|
|
|
|
You should be presented a page with lots of `(run)` links, where when you click
|
|
them it will execute the benchmark and then display the result.
|
|
|
|
## Benchmark Architecture
|
|
|
|
Currently benchmarks are pretty bare bones. They just use benchmark.js to
|
|
generate statistics which are then rendered to the screen. Benchmarks are listed
|
|
one-by-one in `index.html` where a `td` exists for each benchmark. In `index.js`
|
|
each of the `td`'s `id` properties are hooked up to an actual function to
|
|
benchmark, depending on what's being benchmarked.
|
|
|
|
Relevant files are:
|
|
|
|
* `index.html` - the page showing all benchmarks
|
|
* `index.js` - the driver JS for all benchmarks
|
|
* `globals.js` - global JS functions imported by all other benchmarks
|
|
* `js-bencharks.js` - the JS functions that we're benchmarking
|
|
* `src/lib.rs` - the Rust/`wasm-bindgen` functions we're benchmarking
|
|
* `raw.wast`/`raw.wasm` - a raw handwritten WebAssembly file used in some
|
|
benchmarks. A compiled version of this is checked into the repository.
|