Created
February 4, 2024 17:42
-
-
Save onliniak/40958aed02c44ab71d72204cde437fbe to your computer and use it in GitHub Desktop.
wasm nixos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run = "crystal run main.cr" | |
# crystal build main.cr --cross-compile --target wasm32-unknown-wasi | |
# wasm2wat main.wasm -o main.wat | |
## wasm2c main.wasm --no-debug-names -o main.c | |
## gcc -O3 -march=native -c main.c -o main.o | |
entrypoint = "main.cr" | |
[nix] | |
channel = "stable-23_11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs }: { | |
deps = [ | |
pkgs.crystal | |
pkgs.shards | |
pkgs.openssl | |
pkgs.pkg-config | |
pkgs.wabt | |
pkgs.glibc.dev | |
pkgs.gcc | |
pkgs.lld | |
pkgs.llvm | |
pkgs.libllvm | |
pkgs.pcre.dev | |
pkgs.wasmer | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~/WetSkilledAngels$ crystal build --release --no-debug main.cr
~/WetSkilledAngels$ time ./main
"4\n"
real 0m0.118s
user 0m0.013s
sys 0m0.032s
~/WetSkilledAngels$ time iwasm main.aot
4
real 0m0.038s
user 0m0.016s
sys 0m0.022s
~/WetSkilledAngels$ time ./main
"4\n"
real 0m0.050s
user 0m0.026s
sys 0m0.014s
~/WetSkilledAngels$
~/WetSkilledAngels$ ./main
WASM 35.97 ( 27.80ms) (±38.53%) 37.7kB/op 1956003.75× slower
Native 70.35M ( 14.21ns) (±49.93%) 0.0B/op fastest