Wasm, officially called Web-Assembly, is an Optimized code format and API for the web. It can significantly enhance the performance of websites. Its version 1.0 was released in 2017 and has become an official W3C standard. Its support has quickly spread to all the major browser systems for use cases like in-browser: video editing, 3D games, VR and augmented reality, P2P services, simulations, and more. Wasm is not only limited to use with browsers but is being used in mobile and edge-based environments for performance enhancements.
Why is Benchmarking important?
Instead,.wasm files can be checked and assembled in a single pass, allowing for "Streaming Compilation": a browser can begin compiling and executing them as soon as it downloads them, precisely like streaming movies.
Points like these make it a very interesting topic for having a practical example to see which one is better and by how much.
There has been a lot of benchmarking done by various parties in this regard, and have produced some remarkable results.
There has been a lot of benchmarking to evaluate how well wasm works. Consider the benchmarking of the K-means clustering algorithm.
k-means clustering is a vector quantization method that seeks to partition n observations into k clusters. Each observation belongs to the cluster with the nearest mean (cluster centres or cluster centroid), which serves as the cluster's prototype.
As evident, with an increase in the k value (iterations), the performance of wasm proves to be better (4X than the JS counterpart).
What are the benchmarking outcomes during the test ?
Below are the benchmarks obtained during the testing :
Looking at these benchmarks, I was shocked but in a happy way. Happy to see what a great improvement Web Assembly has to offer to the Web world.
Use Cases of Wasm
Web Assembly has a vast variety of use cases with the ability to boost performances in all domains accessible.
Some possible uses of Web Assembly are :
Inside the browser
- Better execution speeds for existing toolkits and language on the web (C/C++, Rust, Go, etc.)
- Image/video editing
- High-end gaming
- CAD application
- Virtual Reality
- Local web Server
- Fat clients for enterprise applications (e.g ., DataBases)