Return to search

WebAssembly Performance Analysis: A Comparative Study of C++ and Rust Implementations

Background: In the contemporary digital landscape, web browsers have evolved from mere text renderers to sophisticated platforms supporting interactive 3D visualizations, multimedia, and gaming applications. This evolution has been catalysed by the advent of WebAssembly, a binary instruction format designed to enhance browser performance by executing high-level language code with near-native efficiency. This thesis investigates the performance implications of WebAssembly modules generated from programs written in C++ and Rust programming languages. Objectives: The primary aim is to assess the performance of WebAssembly(Wasm) modules generated from Rust and C++ programming languages. This involves conducting a mini literature review on WebAssembly compilation, C++, and Rust semantics and compilation processes. Furthermore, the study aims to evaluate the performance of C++ and Rust Wasm modules encompassing tasks such as sorting and matrix multiplication. Performance metrics including execution time and file size of the obtained Wasm modules are analysed using Chrome’s DevTools. Ultimately, the research endeavours to provide insights into Wasm performance. Method: In this study, the research method relies on a quantitative experimental approach by writing programs like quicksort and matrix multiplication in both C++and Rust programming languages and compiling them into Wasm modules using compilers like Emscripten for C++ and RustC for Rust programs respectively. Since, the Wasm module is a byte code type it is converted into WebAssembly Text Format (WAT) file for obtaining the readable machine instructions. Performance metrics like execution speed, file size, and number of assembly instructions like add, load, loop, etc are evaluated and calculated using Chrome’s DevTools. Results: The study which involves a comparative analysis between Wasm modules of C++ and Rust programming languages showcase that the performance of the Rust Wasm module is more fast and efficient in terms of execution time, file size, etc than C++ Wasm module. The findings aim to assist developers in making informed decisions regarding programming language selection for web development, thereby enhancing the efficiency of web applications. Conclusion: The study has determined that the performance characteristics of WebAssembly modules originating from both C++ and Rust programs vary. The results underscore the superior speed and efficiency of Rust-generated Wasm modules when contrasted with those produced from C++. These insights establish a robust basis for future research and optimization initiatives within the field of web development.

Identiferoai:union.ndltd.org:UPSALLA1/oai:DiVA.org:bth-26632
Date January 2024
CreatorsAiyatham Prabakar, Rishi Kiran
PublisherBlekinge Tekniska Högskola, Institutionen för datavetenskap
Source SetsDiVA Archive at Upsalla University
LanguageEnglish
Detected LanguageEnglish
TypeStudent thesis, info:eu-repo/semantics/bachelorThesis, text
Formatapplication/pdf
Rightsinfo:eu-repo/semantics/openAccess

Page generated in 0.3515 seconds