Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update effekt benchmarks #62

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
55 changes: 27 additions & 28 deletions benchmarks/effekt/Makefile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 7 additions & 5 deletions benchmarks/effekt/countdown/main.effekt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
12 changes: 7 additions & 5 deletions benchmarks/effekt/fibonacci_recursive/main.effekt
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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)
}
12 changes: 7 additions & 5 deletions benchmarks/effekt/iterator/main.effekt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
}
16 changes: 9 additions & 7 deletions benchmarks/effekt/nqueens/main.effekt
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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)
}
14 changes: 8 additions & 6 deletions benchmarks/effekt/parsing_dollars/main.effekt
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -31,7 +31,7 @@ def parse(a: Int): Unit / {Read, Emit, Stop} = {
do Stop()
}
}

def sum { action: () => Unit / Emit } = {
var s = 0;
try {
Expand Down Expand Up @@ -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)
}
14 changes: 8 additions & 6 deletions benchmarks/effekt/product_early/main.effekt
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down Expand Up @@ -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)
}
12 changes: 7 additions & 5 deletions benchmarks/effekt/resume_nontail/main.effekt
Original file line number Diff line number Diff line change
@@ -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 }

Expand Down Expand Up @@ -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)
}
16 changes: 9 additions & 7 deletions benchmarks/effekt/tree_explore/main.effekt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,8 +14,8 @@ def maximum(l: List[Int]): Int =
}


effect Choose {
def choose(): Boolean
interface Choose {
def choose(): Bool
}

type Tree {
Expand Down Expand Up @@ -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)
}
18 changes: 10 additions & 8 deletions benchmarks/effekt/triples/main.effekt
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down Expand Up @@ -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)
}
6 changes: 2 additions & 4 deletions systems/effekt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading