From fae16776e77ba5eee6d6e7cc979480ac08fe6b4a Mon Sep 17 00:00:00 2001 From: acheronfail Date: Mon, 18 Dec 2023 23:08:31 +1030 Subject: [PATCH] add kotlin and scala --- .gitignore | 5 ++++- count.kt | 8 ++++++++ count.scala | 10 ++++++++++ justfile | 31 +++++++++++++++++++------------ 4 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 count.kt create mode 100644 count.scala diff --git a/.gitignore b/.gitignore index ac4501e..7d0d0a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ build results -*.class \ No newline at end of file +*.class +java/ +kotlin/ +scala/ \ No newline at end of file diff --git a/count.kt b/count.kt new file mode 100644 index 0000000..48d9e5f --- /dev/null +++ b/count.kt @@ -0,0 +1,8 @@ +fun main() { + var i = 0 + while (i < 1_000_000_000) { + i++; + } + + println(i) +} diff --git a/count.scala b/count.scala new file mode 100644 index 0000000..5f401c9 --- /dev/null +++ b/count.scala @@ -0,0 +1,10 @@ +object Count { + def main(args: Array[String]) = { + var num = 0 + while (num < 1_000_000_000) { + num += 1 + } + + println(num) + } +} diff --git a/justfile b/justfile index b856cc9..09d35c9 100644 --- a/justfile +++ b/justfile @@ -21,20 +21,27 @@ prepare: mkdir {{r}} {{b}} build: prepare - gcc -O3 ./count.c -o {{b}}/c-gcc - clang -O3 ./count.c -o {{b}}/c-clang - rustc -C opt-level=3 ./count.rs -o {{b}}/rust + gcc -O3 ./count.c -o {{b}}/c-gcc + clang -O3 ./count.c -o {{b}}/c-clang + rustc -C opt-level=3 ./count.rs -o {{b}}/rust gfortran -O3 ./count.f90 -o {{b}}/fortran - javac count.java - echo "#!/usr/bin/env -S java count" > {{b}}/java - echo "#!/usr/bin/env -S ruby \n$(cat count.rb)" > {{b}}/ruby - echo "#!/usr/bin/env -S python3 \n$(cat count.py)" > {{b}}/python3 - echo "#!/usr/bin/env -S node \n$(cat count.js)" > {{b}}/node - echo "#!/usr/bin/env -S deno run \n$(cat count.js)" > {{b}}/deno - echo "#!/usr/bin/env -S bun \n$(cat count.js)" > {{b}}/bun + javac count.java -d java + mkdir -p scala && scalac count.scala -d scala + kotlinc count.kt -include-runtime -d kotlin/kotlin.jar + echo "#!/usr/bin/env -S scala -classpath scala Count" > {{b}}/scala + echo "#!/usr/bin/env -S java -jar kotlin/kotlin.jar " > {{b}}/kotlin + echo "#!/usr/bin/env -S java -cp java count " > {{b}}/java + echo "#!/usr/bin/env -S ruby \n$(cat count.rb)" > {{b}}/ruby + echo "#!/usr/bin/env -S python3 \n$(cat count.py)" > {{b}}/python3 + echo "#!/usr/bin/env -S node \n$(cat count.js)" > {{b}}/node + echo "#!/usr/bin/env -S deno run \n$(cat count.js)" > {{b}}/deno + echo "#!/usr/bin/env -S bun \n$(cat count.js)" > {{b}}/bun for f in {{b}}/*; do chmod +x "$f"; done -run: build +run what: build + {{b}}/{{what}} + +all: build #!/usr/bin/env bash set -euxo pipefail for f in {{b}}/*; do @@ -57,6 +64,6 @@ run: build timers "$f" >/dev/null 2> >(jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1')'}' "$out" | sponge "$out") done -count: run +count: all node ./scripts/summary.js > {{r}}/table.txt cat {{r}}/table.txt \ No newline at end of file