From 174738a725dc4826cfa18cd6cbf70d64fa52bfc9 Mon Sep 17 00:00:00 2001 From: Serkan Muhcu Date: Wed, 30 Oct 2024 13:02:58 +0100 Subject: [PATCH] Update effekt benchmarks --- Makefile | 2 +- benchmarks/effekt/Makefile | 55 +++++++++---------- benchmarks/effekt/countdown/main.effekt | 12 ++-- .../effekt/fibonacci_recursive/main.effekt | 12 ++-- benchmarks/effekt/iterator/main.effekt | 12 ++-- benchmarks/effekt/nqueens/main.effekt | 16 +++--- benchmarks/effekt/parsing_dollars/main.effekt | 14 +++-- benchmarks/effekt/product_early/main.effekt | 14 +++-- benchmarks/effekt/resume_nontail/main.effekt | 12 ++-- benchmarks/effekt/tree_explore/main.effekt | 16 +++--- benchmarks/effekt/triples/main.effekt | 18 +++--- systems/effekt/Dockerfile | 6 +- 12 files changed, 102 insertions(+), 87 deletions(-) diff --git a/Makefile b/Makefile index f23669c..9a2c8b9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DOCKERHUB=effecthandlers/effect-handlers -all: bench_eff bench_hia bench_koka bench_links bench_ocaml +all: bench_effekt bench_eff bench_hia bench_koka bench_links bench_ocaml system_base: docker build -t $(DOCKERHUB):base systems diff --git a/benchmarks/effekt/Makefile b/benchmarks/effekt/Makefile index bb95185..5eeb3eb 100644 --- a/benchmarks/effekt/Makefile +++ b/benchmarks/effekt/Makefile @@ -1,40 +1,39 @@ bench: build hyperfine --export-csv results.csv \ - 'countdown/main 200000000' \ - 'fibonacci_recursive/main 42' \ - 'product_early/main 100000' \ - 'iterator/main 40000000' \ - 'nqueens/main 12' \ - 'tree_explore/main 16' \ - 'triples/main 300' \ - 'parsing_dollars/main 20000' \ - 'resume_nontail/main 20000' + 'countdown/out/main 200000000' \ + 'fibonacci_recursive/out/main 42' \ + 'product_early/out/main 100000' \ + 'iterator/out/main 40000000' \ + 'nqueens/out/main 12' \ + 'tree_explore/out/main 16' \ + 'triples/out/main 300' \ + 'parsing_dollars/out/main 20000' \ + 'resume_nontail/out/main 20000' test: build - cd countdown ; ./main 5 > actual ; echo 0 > expected ; diff expected actual - cd fibonacci_recursive ; ./main 5 > actual ; echo 5 > expected ; diff expected actual - cd product_early ; ./main 5 > actual ; echo 0 > expected ; diff expected actual - cd iterator ; ./main 5 > actual ; echo 15 > expected ; diff expected actual - cd nqueens ; ./main 5 > actual ; echo 10 > expected ; diff expected actual - cd tree_explore ; ./main 5 > actual ; echo 946 > expected ; diff expected actual - cd triples ; ./main 10 > actual ; echo 779312 > expected ; diff expected actual - cd parsing_dollars ; ./main 10 > actual ; echo 55 > expected ; diff expected actual - cd resume_nontail ; ./main 5 > actual ; echo 37 > expected ; diff expected actual + cd countdown ; ./out/main 5 > actual ; echo 0 > expected ; diff expected actual + cd fibonacci_recursive ; ./out/main 5 > actual ; echo 5 > expected ; diff expected actual + cd product_early ; ./out/main 5 > actual ; echo 0 > expected ; diff expected actual + cd iterator ; ./out/main 5 > actual ; echo 15 > expected ; diff expected actual + cd nqueens ; ./out/main 5 > actual ; echo 10 > expected ; diff expected actual + cd tree_explore ; ./out/main 5 > actual ; echo 946 > expected ; diff expected actual + cd triples ; ./out/main 10 > actual ; echo 779312 > expected ; diff expected actual + cd parsing_dollars ; ./out/main 10 > actual ; echo 55 > expected ; diff expected actual + cd resume_nontail ; ./out/main 5 > actual ; echo 37 > expected ; diff expected actual build: - cd countdown ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd fibonacci_recursive ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd product_early ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd iterator ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd nqueens ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd tree_explore ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd triples ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd parsing_dollars ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml - cd resume_nontail ; effekt.sh --backend ml --compile main.effekt ; mlton -default-type int64 -output main out/main.sml + cd countdown ; effekt.sh --backend llvm --build main.effekt + cd fibonacci_recursive ; effekt.sh --backend llvm --build main.effekt + cd product_early ; effekt.sh --backend llvm --build main.effekt + cd iterator ; effekt.sh --backend llvm --build main.effekt + cd nqueens ; effekt.sh --backend llvm --build main.effekt + cd tree_explore ; effekt.sh --backend llvm --build main.effekt + cd triples ; effekt.sh --backend llvm --build main.effekt + cd parsing_dollars ; effekt.sh --backend llvm --build main.effekt + cd resume_nontail ; effekt.sh --backend llvm --build main.effekt clean: -rm -r */out/ - -rm */main -rm results.csv -rm */expected -rm */actual diff --git a/benchmarks/effekt/countdown/main.effekt b/benchmarks/effekt/countdown/main.effekt index 336255a..64fab76 100644 --- a/benchmarks/effekt/countdown/main.effekt +++ b/benchmarks/effekt/countdown/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string effect Get() : Int effect Set(i: Int): Unit @@ -25,7 +25,9 @@ def run(n: Int) = { } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } \ No newline at end of file diff --git a/benchmarks/effekt/fibonacci_recursive/main.effekt b/benchmarks/effekt/fibonacci_recursive/main.effekt index 5c912bd..b6e0b34 100644 --- a/benchmarks/effekt/fibonacci_recursive/main.effekt +++ b/benchmarks/effekt/fibonacci_recursive/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string def fibonacci(n: Int): Int = if (n == 0) { @@ -13,7 +13,9 @@ def fibonacci(n: Int): Int = } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = fibonacci(n); println(r) } \ No newline at end of file diff --git a/benchmarks/effekt/iterator/main.effekt b/benchmarks/effekt/iterator/main.effekt index 2cf545c..b13c2ab 100644 --- a/benchmarks/effekt/iterator/main.effekt +++ b/benchmarks/effekt/iterator/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string effect Emit(e: Int): Unit @@ -25,7 +25,9 @@ def run(n: Int) = { } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } diff --git a/benchmarks/effekt/nqueens/main.effekt b/benchmarks/effekt/nqueens/main.effekt index a94ebf0..b5c03f9 100644 --- a/benchmarks/effekt/nqueens/main.effekt +++ b/benchmarks/effekt/nqueens/main.effekt @@ -1,16 +1,16 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string type Solution = List[Int] -effect Search { +interface Search { def pick(size: Int): Int def fail(): Nothing } -def safe(queen: Int, diag: Int, xs: Solution): Boolean = +def safe(queen: Int, diag: Int, xs: Solution): Bool = xs match { case Nil() => true case Cons(q, qs) => if (queen != q && queen != q + diag && queen != q - diag) { @@ -52,7 +52,9 @@ def run(n: Int): Int = } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } diff --git a/benchmarks/effekt/parsing_dollars/main.effekt b/benchmarks/effekt/parsing_dollars/main.effekt index 16e0418..1589ff7 100644 --- a/benchmarks/effekt/parsing_dollars/main.effekt +++ b/benchmarks/effekt/parsing_dollars/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string type Chr = Int @@ -31,7 +31,7 @@ def parse(a: Int): Unit / {Read, Emit, Stop} = { do Stop() } } - + def sum { action: () => Unit / Emit } = { var s = 0; try { @@ -73,7 +73,9 @@ def run(n: Int) = sum { catch { feed(n) { parse(0) } } } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 10 }; + val n = on[WrongFormat].default{10}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } \ No newline at end of file diff --git a/benchmarks/effekt/product_early/main.effekt b/benchmarks/effekt/product_early/main.effekt index 248d0c5..0b96b38 100644 --- a/benchmarks/effekt/product_early/main.effekt +++ b/benchmarks/effekt/product_early/main.effekt @@ -1,9 +1,9 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string -effect Abort { +interface Abort { def done[A](i: Int): A } @@ -40,7 +40,9 @@ def run(n: Int) = { } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } diff --git a/benchmarks/effekt/resume_nontail/main.effekt b/benchmarks/effekt/resume_nontail/main.effekt index f43c630..82fe517 100644 --- a/benchmarks/effekt/resume_nontail/main.effekt +++ b/benchmarks/effekt/resume_nontail/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string def abs(i: Int): Int = if (i < 0) { 0 - i } else { i } @@ -35,7 +35,9 @@ def repeat(n: Int): Int = { } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = repeat(n); println(r) } diff --git a/benchmarks/effekt/tree_explore/main.effekt b/benchmarks/effekt/tree_explore/main.effekt index e094f3d..a4c0bfd 100644 --- a/benchmarks/effekt/tree_explore/main.effekt +++ b/benchmarks/effekt/tree_explore/main.effekt @@ -1,7 +1,7 @@ -import immutable/list -import immutable/option -import io/args -import text/string +import list +import option +import args +import string def abs(n: Int): Int = if (n < 0) 0 - n else n @@ -14,8 +14,8 @@ def maximum(l: List[Int]): Int = } -effect Choose { - def choose(): Boolean +interface Choose { + def choose(): Bool } type Tree { @@ -67,7 +67,9 @@ def run(n: Int) = { } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 5 }; + val n = on[WrongFormat].default{5}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n); println(r) } diff --git a/benchmarks/effekt/triples/main.effekt b/benchmarks/effekt/triples/main.effekt index c57318f..df51340 100644 --- a/benchmarks/effekt/triples/main.effekt +++ b/benchmarks/effekt/triples/main.effekt @@ -1,15 +1,15 @@ -import io/args -import immutable/list -import immutable/option -import text/string +import list +import option +import args +import string record Triple(a: Int, b: Int, c: Int) -effect Flip { - def flip(): Boolean +interface Flip { + def flip(): Bool } -effect Fail { +interface Fail { def fail(): Nothing } @@ -48,7 +48,9 @@ def run(n: Int, s: Int): Int = } def main() = { - val n = commandLineArgs().headOption.getOrElse { "" }.toInt.getOrElse { 10 }; + val n = on[WrongFormat].default{10}{ + commandLineArgs().headOption.getOrElse{""}.toInt + } val r = run(n, n); println(r) } diff --git a/systems/effekt/Dockerfile b/systems/effekt/Dockerfile index cb610fa..bb4597b 100644 --- a/systems/effekt/Dockerfile +++ b/systems/effekt/Dockerfile @@ -6,10 +6,8 @@ RUN sudo apt install -y openjdk-19-jre # ENV JAVA_HOME /usr/lib/jvm/java-19-openjdk-amd64 RUN sudo apt install -y npm RUN sudo apt install -y libgmp-dev -RUN wget https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz -RUN tar -xzf mlton-20210117-1.amd64-linux-glibc2.31.tgz -ENV PATH="/home/ubuntu/mlton-20210117-1.amd64-linux-glibc2.31/bin:$PATH" -RUN wget https://github.com/effekt-lang/effekt/releases/download/v0.2.1/effekt.tgz +RUN sudo apt install -y llvm-15 +RUN wget https://github.com/effekt-lang/effekt/releases/latest/download/effekt.tgz RUN sudo npm install -g effekt.tgz # Final steps