This project demonstrates a multi-language, multi-platform compilation and benchmarking setup for C, Rust, and Go programs targeting both native (aarch64 - raspberry pi 4b) and WebAssembly (WASM) environments.
The project is organized into multiple directories, each representing a separate module. Within each directory, the source files are located in the src
subdirectory, and the compiled outputs are placed in either the wasm
directory for WebAssembly modules or the bin
directory for native binaries. binaries and wasm files available in the repository are alligned with the current version of the code.
/<module_name>/src/
: Contains source files for the module. Supports.c
,.rs
, and.go
files./<module_name>/wasm/
: Contains compiled WebAssembly modules./<module_name>/bin/
: Contains compiled native binaries.
This Bash script automates the compilation process fo source files into both WebAssembly modules and native binaries.
- C files: Uses
clang
for native arm64 compilation andclang
with thewasi-sdk
for WebAssembly compilation. - Rust files: Utilizes
rustc
for both WebAssembly (with thewasm32-wasi
target) and native arm64 (withclang
as the linker) compilation. - Go files: Employs
tinygo
both for WebAssembly (with thewasi
target) and native arm64 compilation.
This Bash script facilitates the benchmarking of compiled binaries and WebAssembly modules for each module in the project. It runs each compiled output multiple times and records the execution time for each run. The script generates a timestamped output file containing the benchmark results that can be used for further analysis.
- Setup: Ensure all dependencies are correctly installed and accessible in your environment and you are in a aarch64 environment.
- Compiling the Code: Execute the
compile
script from the root of the project directory to compile all source files into WebAssembly modules and native binaries. - Running Benchmarks: Execute the
run
script to benchmark the compiled outputs.
- WASI SDK for C compilation to WebAssembly.
- Rust compiler (
rustc
) withwasm32-wasi
andaarch64-unknown-linux-gnu
targets configured. - Go compiler (
go
) and TinyGo for Go source compilation. aarch64-linux-gnu-gcc
for compiling native aarch64 binaries. (cross-compilation)nice
tool for setting process priority.- wasmtime and wasmer for running WebAssembly modules.
Ensure all dependencies are correctly installed and accessible in your environment before running the scripts.
A sample benchmark and related analysis is available in the results directory.