diff --git a/fib_tests.sh b/fib_tests.sh index 9334147..a78f565 100755 --- a/fib_tests.sh +++ b/fib_tests.sh @@ -11,7 +11,24 @@ echo "Compile Straight" touch csc_out.wasm && rm csc_out.wasm && scheme --script ./partial_eval.scm fib.kp && time echo $NUMBER | wasmtime ./csc_out.wasm #cp csc_out.wasm comp_fib_dyn.wasm -#exit +echo "Compile Straight 2" +#touch csc_out.wasm && rm csc_out.wasm && scheme --script ./partial_eval.scm fib.kp && time echo $NUMBER | wasm3 ./csc_out.wasm +touch csc_out.wasm && rm csc_out.wasm && scheme --script ./partial_eval.scm fib2.kp && time echo $NUMBER | wasmtime ./csc_out.wasm + +echo "Python" +time python3 ./fib.py $NUMBER + +echo "Rust Wasm Debug" +pushd rust_fib +cargo build --target=wasm32-wasi && time echo $NUMBER | wasmtime target/wasm32-wasi/debug/rust_let.wasm +popd + +echo "Rust Wasm Release" +pushd rust_fib +cargo build --release --target=wasm32-wasi && time echo $NUMBER | wasmtime target/wasm32-wasi/release/rust_let.wasm +popd + +exit echo "Interpret Straight" #touch csc_out.wasm && rm csc_out.wasm && scheme --script ./partial_eval.scm fib.kp no_compile && time echo $NUMBER | wasm3 ./csc_out.wasm @@ -27,19 +44,19 @@ touch csc_out.wasm && rm csc_out.wasm && scheme --script ./partial_eval.scm fib_ echo "Chez Scheme" time scheme --script ./fib.scm $NUMBER -# -#echo "Chez Scheme Let" -#time scheme --script ./fib_let.scm $NUMBER -# -#echo "Python" -#time python3 ./fib.py $NUMBER -# -#echo "Python Let" -#time python3 ./fib_let.py $NUMBER -# -#echo "C" -#clang-11 fib.c -o fib && time ./fib $NUMBER -# -#echo "C let" -#clang-11 fib_let.c -o fib_let && time ./fib_let $NUMBER + +echo "Chez Scheme Let" +time scheme --script ./fib_let.scm $NUMBER + +echo "Python" +time python3 ./fib.py $NUMBER + +echo "Python Let" +time python3 ./fib_let.py $NUMBER + +echo "C" +clang-11 fib.c -o fib && time ./fib $NUMBER + +echo "C let" +clang-11 fib_let.c -o fib_let && time ./fib_let $NUMBER diff --git a/rust_fib/Cargo.lock b/rust_fib/Cargo.lock new file mode 100644 index 0000000..b108dd7 --- /dev/null +++ b/rust_fib/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rust_let" +version = "0.1.0" diff --git a/rust_fib/Cargo.toml b/rust_fib/Cargo.toml new file mode 100644 index 0000000..faed3ac --- /dev/null +++ b/rust_fib/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust_let" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust_fib/src/main.rs b/rust_fib/src/main.rs new file mode 100644 index 0000000..f55fc9c --- /dev/null +++ b/rust_fib/src/main.rs @@ -0,0 +1,18 @@ + +use std::io; + +fn fib(n: i64) -> i64 { + match n { + 0 => 1, + 1 => 1, + o => fib(o-1) + fib(o-2), + } +} + +fn main() { + println!("enter number to fib:"); + let mut buffer = String::new(); + let stdin = io::stdin(); + stdin.read_line(&mut buffer).unwrap(); + println!("{}", fib(buffer.trim().parse::().unwrap())); +} diff --git a/shell.nix b/shell.nix index 8a9b55a..2aebb58 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,8 @@ -with import { }; - +let + moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); + nixpkgs = import { overlays = [ moz_overlay ]; }; +in with nixpkgs; mkShell { LANG="en_US.UTF-8"; nativeBuildInputs = [ @@ -13,5 +15,8 @@ mkShell { wasm3 wasmer kakoune + #(rustChannelOf { rustToolchain = ./rust-toolchain; }).rust + #(rustChannelOf { date = "2022-04-10"; channel = "nightly"; targets = [ "wasm32-wasi" ]; }).rust + (latest.rustChannels.nightly.rust.override { targets = [ "wasm32-wasi" ]; }) ]; }