dotnet-webassembly icon indicating copy to clipboard operation
dotnet-webassembly copied to clipboard

Benchmark Project

Open martindevans opened this issue 1 year ago • 3 comments

Added a benchmark project. Currently only one benchmark which compares performance to wasmtime, but it's easy to add more. This project actually beats wasmtime!

The benchmark runs a function called bench, which is adapted from a random Rust project I had lying around (calculating various rocket nozzle parameters). I'm happy to share the code for this if you want, but I'm not sure what the best way to do it is - would you just want the entire Rust project included in the wasm folder?

martindevans avatar Jun 30 '24 14:06 martindevans

I've changed the Rust compile options to optimise for size, using:

[profile.release]
lto = true
panic = "abort"
opt-level = "s"

Which has reduced the file size down to 167KB. Is that more acceptable? I would prefer to use a "real world" test file if at all possible, rather than something hand written, because I think that leads to a more realistic benchmark result.

martindevans avatar Jul 02 '24 12:07 martindevans

Yeah, that size is a lot better. I'm not sure if I want to merge this, though: it's adding maintenance surface area to a project I only barely have enough time to keep alive. I'm definitely not trying to compete with wasmtime.

Maybe a blog or (if you're particularly ambitious) a Youtube channel might be more appropriate?

RyanLamansky avatar Jul 03 '24 00:07 RyanLamansky

My motivation in adding it is that it can be used to drive future optimisations. Benchmarks can be added to cover a specific area and then that's a good starting pointing for profiling and optimising performance of that area.

Personally I think it is worth including, there should be very little maintenance overhead, but that's your call of course! I can use it locally for optimisations whether or not it's merged, so I'm not too worried if you want to close this PR :)

I actually didn't intend to PR the wasmtime comparison benchmark initially. It was just an easy one to put together and I was curious how a relatively simple translation to IL would compare to the much more complex wasmtime project. I fully expected wasmtime to win. I only polished it up to make the PR because of the unexpected result!

martindevans avatar Jul 03 '24 01:07 martindevans