Skip to content

Commit 82c3804

Browse files
authored
Merge pull request #472 from nuald/staged-scala
Staged Scala test has been embedded into the suite.
2 parents dbb27b3 + cc4f911 commit 82c3804

File tree

6 files changed

+46
-44
lines changed

6 files changed

+46
-44
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Supports two mode:
6868

6969
| Language | Time, s | Memory, MiB | Energy, J |
7070
| :--------------------- | -----------------------: | ------------------------------------------------: | -------------------------: |
71+
| Scala (Staged) | 0.500<sub>±0.011</sub> | 214.99<sub>±04.56</sub> + 21.33<sub>±01.86</sub> | 28.38<sub>±02.06</sub> |
7172
| Racket (Staged) | 1.300<sub>±0.000</sub> | 100.79<sub>±00.40</sub> + 0.00<sub>±00.00</sub> | 47.18<sub>±00.05</sub> |
7273
| C++/g++ | 1.323<sub>±0.000</sub> | 1.84<sub>±00.03</sub> + 0.00<sub>±00.00</sub> | 52.88<sub>±00.06</sub> |
7374
| Java | 1.582<sub>±0.000</sub> | 39.81<sub>±00.08</sub> + 1.19<sub>±00.04</sub> | 61.57<sub>±00.09</sub> |
@@ -130,6 +131,7 @@ Supports two mode:
130131
| Racket (Staged) | 14.379<sub>±0.428</sub> | 100.46<sub>±00.16</sub> + 76.88<sub>±02.04</sub> | 572.08<sub>±14.26</sub> |
131132
| Kotlin/JVM | 14.396<sub>±0.014</sub> | 42.93<sub>±00.21</sub> + 2.18<sub>±00.22</sub> | 592.87<sub>±01.55</sub> |
132133
| Rust | 15.057<sub>±0.014</sub> | 0.90<sub>±00.01</sub> + 1.10<sub>±00.02</sub> | 594.38<sub>±02.79</sub> |
134+
| Scala (Staged) | 15.065<sub>±0.646</sub> | 216.61<sub>±02.00</sub> + 103.20<sub>±07.08</sub> | 742.04<sub>±18.57</sub> |
133135
| D/gdc | 15.070<sub>±0.006</sub> | 6.27<sub>±00.02</sub> + 1.44<sub>±00.02</sub> | 636.33<sub>±01.52</sub> |
134136
| Zig | 15.107<sub>±0.007</sub> | 0.90<sub>±00.02</sub> + 1.41<sub>±00.01</sub> | 622.38<sub>±01.04</sub> |
135137
| C/clang | 15.113<sub>±0.005</sub> | 0.86<sub>±00.01</sub> + 0.88<sub>±00.03</sub> | 648.78<sub>±04.04</sub> |

brainfuck/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ executables := \
3333

3434
artifacts := $(executables) \
3535
target/bf_scala.jar \
36+
target/bf_staged_scala.jar \
3637
target/bf2-kt.jar \
3738
target/bf.exe \
3839
target/bf.class
@@ -85,6 +86,9 @@ target/bin_swift: bf.swift | target
8586
target/bf_scala.jar: bf.scala | target
8687
$(SCALAC_BUILD)
8788

89+
target/bf_staged_scala.jar: bf-staged.scala | target
90+
$(SCALAC_BUILD)
91+
8892
target/bf.exe: bf.cs | target
8993
$(MCS_BUILD)
9094

@@ -181,6 +185,9 @@ $(executable_runners):: run[%] : %
181185
run[target/bf_scala.jar]:: run[%]: %
182186
$(SCALA_RUN) BrainFuck $(BF_SRC)
183187

188+
run[target/bf_staged_scala.jar]:: run[%]: %
189+
$(SCALA_RUN) BrainFuckStaged $(BF_SRC)
190+
184191
run[target/bf.exe]:: run[%]: %
185192
$(MONO_RUN) $(BF_SRC)
186193

brainfuck/scala-staged/src/main/scala/Main.scala renamed to brainfuck/bf-staged.scala

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,44 @@ class Program(text: String, p: Printer):
4949

5050
def run = runOn(Tape(), p)
5151

52-
def notify(msg: String) =
53-
scala.util.Using((java.net.Socket("localhost", 9001)).getOutputStream()) {
52+
object BrainFuckStaged {
53+
def notify(msg: String) = {
54+
scala.util.Using((java.net.Socket("localhost", 9001)).getOutputStream()) {
5455
_.write(msg.getBytes())
56+
}
5557
}
5658

57-
def verify =
58-
val text = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>
59+
def verify = {
60+
val text = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>
5961
---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
60-
val pLeft = Printer(true)
61-
Program(text, pLeft).run
62-
val left = pLeft.checksum
63-
val pRight = Printer(true)
64-
for c <- "Hello World!\n" do
65-
pRight.write(c)
66-
val right = pRight.checksum
67-
if left != right then
62+
val pLeft = Printer(true)
63+
Program(text, pLeft).run
64+
val left = pLeft.checksum
65+
val pRight = Printer(true)
66+
for (c <- "Hello World!\n") {
67+
pRight.write(c)
68+
}
69+
val right = pRight.checksum
70+
if (left != right) {
6871
System.err.println(s"${left} != ${right}")
6972
System.exit(1)
73+
}
74+
}
7075

71-
@main def main(filename : String) : Unit =
72-
verify
73-
val text = scala.util.Using(scala.io.Source.fromFile(filename)) { _.mkString }.get
74-
val p = Printer(sys.env.get("QUIET").isDefined)
75-
76-
notify(s"Scala (Staged)\t${ProcessHandle.current().pid()}")
77-
val s = System.nanoTime
78-
Program(text, p).run
79-
val elapsed = (System.nanoTime - s) / 1e9
80-
notify("stop")
81-
82-
System.err.println(s"time: $elapsed s")
83-
if p.quiet then
84-
System.out.println(s"Output checksum: ${p.checksum}")
76+
def main(args: Array[String]): Unit = {
77+
val filename = args(0)
78+
verify
79+
val text = scala.util.Using(scala.io.Source.fromFile(filename)) { _.mkString }.get
80+
val p = Printer(sys.env.get("QUIET").isDefined)
81+
82+
notify(s"Scala (Staged)\t${ProcessHandle.current().pid()}")
83+
val s = System.nanoTime
84+
Program(text, p).run
85+
val elapsed = (System.nanoTime - s) / 1e9
86+
notify("stop")
87+
88+
System.err.println(s"time: $elapsed s")
89+
if p.quiet then
90+
System.out.println(s"Output checksum: ${p.checksum}")
91+
}
92+
}

brainfuck/scala-staged/build.sbt

Lines changed: 0 additions & 14 deletions
This file was deleted.

brainfuck/scala-staged/project/build.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

common/commands.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ GCC_GO_BUILD = gccgo $(GCC_FLAGS) -o $@ $^
2121
GDC_BUILD = gdc -o $@ -O3 -frelease -finline -fbounds-check=off $^
2222
GHC_BUILD = ghc -v0 -O2 -fforce-recomp -Wall $^ -o $@ -outputdir $(@D)
2323
GO_BUILD = GO111MODULE=auto go build -o $@ $^
24-
JAVAC_BUILD = javac --release 19 -Xlint:unchecked -d $(@D) $^
25-
KOTLINC_BUILD = kotlinc -include-runtime -jvm-target 18 -d $@ $^
24+
JAVAC_BUILD = javac --release 21 -Xlint:unchecked -d $(@D) $^
25+
KOTLINC_BUILD = kotlinc -include-runtime -jvm-target 20 -d $@ $^
2626
LDC2_BUILD = ldc2 -of$@ -O5 -release -boundscheck=off $^
2727
MCS_BUILD = mcs -debug- -optimize+ -out:$@ $^
2828
MLTON_BUILD = mlton -output $@ $^
@@ -31,7 +31,7 @@ NIM_GCC_BUILD = nim c -o:$@ --cc:gcc $(NIM_FLAGS) $^
3131
RUSTC_BUILD = rustc $(RUSTC_FLAGS) -C opt-level=3 -C lto -C codegen-units=1 -C panic=abort -C strip=symbols -o $@ $^
3232
RUST_CLIPPY = clippy-driver -o $@.clippy $^
3333
SWIFTC_BUILD = swiftc -parse-as-library -O -lto=llvm-full -cross-module-optimization $(LIBNOTIFY_FLAGS) -import-objc-header ../common/libnotify/libnotify.h -o $@ $^
34-
SCALAC_BUILD = scalac -java-output-version 19 -d $@ $^
34+
SCALAC_BUILD = scalac -java-output-version 21 -d $@ $^
3535
VALAC_CLANG_BUILD = valac $^ --cc=clang -D CLANG_TEST $(VALAC_FLAGS) -o $@
3636
VALAC_GCC_BUILD = valac $^ --cc=gcc -D GCC_TEST $(VALAC_FLAGS) -o $@
3737
V_CLANG_BUILD = v $(V_FLAGS) -cc clang -o $@ $^

0 commit comments

Comments
 (0)