aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun.sh90
1 files changed, 31 insertions, 59 deletions
diff --git a/run.sh b/run.sh
index fc5986f..8d33039 100755
--- a/run.sh
+++ b/run.sh
@@ -1,62 +1,34 @@
#!/usr/bin/bash
-echo C
-gcc test.c -o test -O2 -march=native
-hyperfine ./test
-rm test
-
-echo C++
-g++ test.cpp -o test -O2 -march=native
-hyperfine ./test
-rm test
-
-echo Python
-python -m py_compile test.py
-hyperfine "python test.py"
+# Compile
+gcc test.c -o testc -O2 -march=native # C
+g++ test.cpp -o testcpp -O2 -march=native # C++
+python -m py_compile test.py # Python
+javac test.java # Java
+mcs test.cs # C#
+go build -o testgo test.go # Go
+rustc test.rs -C opt-level=2 -C target-cpu=native -o testrs # Rust
+ghc -dynamic -O test.hs -o tesths # Haskell
+
+# Run benchmarks
+run=('./testc' # C
+ './testcpp' # C++
+ 'python test.py' # Python
+ 'java test' # Java
+ 'mono test.exe' # C#
+ 'node test.js' # Node
+ 'perl test.pl' # Perl
+ 'ruby test.rb' # Ruby
+ './testgo' # Go
+ './testrs' # Rust
+ './tesths' # Haskell
+ 'julia test.jl' # Julia
+ 'Rscript test.r' # R
+ 'ecl --shell test.lisp' # Common Lisp
+ 'lua test.lua' # Lua
+)
+echo ${run[@]@Q} | xargs hyperfine --export-json data.json
+
+# Cleanup
+rm testc testcpp test.class test.exe testgo testrs tesths test.o test.hi
rm __pycache__ -r
-
-echo Java
-javac test.java
-hyperfine "java test"
-rm test.class
-
-echo C#
-mcs test.cs
-hyperfine "mono test.exe"
-rm test.exe
-
-echo JavaScript
-hyperfine "node test.js"
-
-echo Perl
-hyperfine "perl test.pl"
-
-echo Ruby
-hyperfine "ruby test.rb"
-
-echo Go
-go build test.go
-hyperfine ./test
-rm test
-
-echo Rust
-rustc test.rs -C opt-level=2 -C target-cpu=native
-hyperfine ./test
-rm test
-
-echo Haskell
-ghc -dynamic test.hs
-hyperfine ./test
-rm test test.o test.hi
-
-echo Julia
-hyperfine "julia test.jl"
-
-echo R
-hyperfine "Rscript test.r"
-
-echo Lisp
-hyperfine "ecl --shell test.lisp"
-
-echo Lua
-hyperfine "lua test.lua"