Skip to content

Commit

Permalink
add kotlin and scala
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Dec 18, 2023
1 parent fae19e7 commit fae1677
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build
results
*.class
*.class
java/
kotlin/
scala/
8 changes: 8 additions & 0 deletions count.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun main() {
var i = 0
while (i < 1_000_000_000) {
i++;
}

println(i)
}
10 changes: 10 additions & 0 deletions count.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Count {
def main(args: Array[String]) = {
var num = 0
while (num < 1_000_000_000) {
num += 1
}

println(num)
}
}
31 changes: 19 additions & 12 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit fae1677

Please sign in to comment.