In terms of runtimes, depending on your choice of language and based on the test results, Chrome might have the best execution speed among all Wasm runtimes. This could be attributed to native implementations of the sorting algorithm inside the JS runtime.ĭepending on the use case, a pure JavaScript algorithm will most likely be slower to a Rust version in most cases. It is worth mentioning that the typed JavaScript version performs in Firefox equally good when compared to the Rust version. If file-size is a major factor, one might consider choosing AssemblyScript, but it is around two times Debugging for Rust is available in CLion, IntelliJ IDEA Ultimate, P圜harm Professional, and GoLand. Languageīased on your observations, it seems like Rust is the safest bet for the fastest execution speed among all tested The below values were obtained via the Chrome browser. To create the storage and retrieval methods, we can use. This framework provides a simple and efficient way to create web APIs in Rust. The pure JavaScript implementation is far in the back. In Rust, we can create a web API using the Actix framework. With all the tests done, it looks like Rust is leading the pack, closely followed by the AssemblyScript version and then the You follow along with your test and discover, that the Go version runs on average 9,546 ms in Edge, 10,668 ms (+12%) in Firefox and 9,717 ms (+2%) Tinygo build -o wasm.wasm -opt = 2 -no-debug -target wasm. Now you got yourself the laid out project and type away the AssemblyScript version in the assembly/index.ts. Setting up the project was a breeze, with following the guide at You start with AssemblyScript, as it is most similar to TypeScript/JavaScript. With the pure JavaScript variants out of the way, you get going on the WebAssembly. In Firefox, it takes around 2976 ms and Chrome is slower with 4904 ms (+65%). The Chrome version takes all the way up to 68,720 ms (+256%)įurther on, you check the typed array version, which runs considerably faster than the dynamic array variant. This has been changed, all variants use stable sorts now.Ĭonst length = 100_000 const arr = new Array( length)Ī test run with 5 repetition in Firefox shows, it takes around 19,273 milliseconds on average with the This comparison was unfair, as Rust and AssemblyScript use a stable one by default. Originally, the Go version used an unstable sort as it is the default. If curious, the test can be reproduced by using the following repository: The tested browsers are Firefox (108.0b6), Edge (1.56) and Chrome (1.110) on an Intel Macbook Pro 2019. Each test will be repeated 5 times and the average will be taken. That will be copiedĥ00 times and each time stable sorted. To compare the speed, the test involves the initialization of an array with 100.000 random values. The thing you are working on involves sorting large amounts of data, so you test a pure JS implementation first. You remember that your friend Jack told you about WebAssembly (Wasm), which supposedly runsįaster than JavaScript (JS), so you decide to check it out. Imagine you are working on the next big thing that runs in the browser, and it requires some heavy-duty code, which need
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |