Skip to content

Staged Scala test has been embedded into the suite. #472

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

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Supports two mode:

| Language | Time, s | Memory, MiB | Energy, J |
| :--------------------- | -----------------------: | ------------------------------------------------: | -------------------------: |
| 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> |
| 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> |
| 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> |
| 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> |
Expand Down Expand Up @@ -130,6 +131,7 @@ Supports two mode:
| 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> |
| 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> |
| 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> |
| 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> |
| 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> |
| 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> |
| 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> |
Expand Down
7 changes: 7 additions & 0 deletions brainfuck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ executables := \

artifacts := $(executables) \
target/bf_scala.jar \
target/bf_staged_scala.jar \
target/bf2-kt.jar \
target/bf.exe \
target/bf.class
Expand Down Expand Up @@ -85,6 +86,9 @@ target/bin_swift: bf.swift | target
target/bf_scala.jar: bf.scala | target
$(SCALAC_BUILD)

target/bf_staged_scala.jar: bf-staged.scala | target
$(SCALAC_BUILD)

target/bf.exe: bf.cs | target
$(MCS_BUILD)

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

run[target/bf_staged_scala.jar]:: run[%]: %
$(SCALA_RUN) BrainFuckStaged $(BF_SRC)

run[target/bf.exe]:: run[%]: %
$(MONO_RUN) $(BF_SRC)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,44 @@ class Program(text: String, p: Printer):

def run = runOn(Tape(), p)

def notify(msg: String) =
scala.util.Using((java.net.Socket("localhost", 9001)).getOutputStream()) {
object BrainFuckStaged {
def notify(msg: String) = {
scala.util.Using((java.net.Socket("localhost", 9001)).getOutputStream()) {
_.write(msg.getBytes())
}
}

def verify =
val text = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>
def verify = {
val text = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>
---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
val pLeft = Printer(true)
Program(text, pLeft).run
val left = pLeft.checksum
val pRight = Printer(true)
for c <- "Hello World!\n" do
pRight.write(c)
val right = pRight.checksum
if left != right then
val pLeft = Printer(true)
Program(text, pLeft).run
val left = pLeft.checksum
val pRight = Printer(true)
for (c <- "Hello World!\n") {
pRight.write(c)
}
val right = pRight.checksum
if (left != right) {
System.err.println(s"${left} != ${right}")
System.exit(1)
}
}

@main def main(filename : String) : Unit =
verify
val text = scala.util.Using(scala.io.Source.fromFile(filename)) { _.mkString }.get
val p = Printer(sys.env.get("QUIET").isDefined)

notify(s"Scala (Staged)\t${ProcessHandle.current().pid()}")
val s = System.nanoTime
Program(text, p).run
val elapsed = (System.nanoTime - s) / 1e9
notify("stop")

System.err.println(s"time: $elapsed s")
if p.quiet then
System.out.println(s"Output checksum: ${p.checksum}")
def main(args: Array[String]): Unit = {
val filename = args(0)
verify
val text = scala.util.Using(scala.io.Source.fromFile(filename)) { _.mkString }.get
val p = Printer(sys.env.get("QUIET").isDefined)

notify(s"Scala (Staged)\t${ProcessHandle.current().pid()}")
val s = System.nanoTime
Program(text, p).run
val elapsed = (System.nanoTime - s) / 1e9
notify("stop")

System.err.println(s"time: $elapsed s")
if p.quiet then
System.out.println(s"Output checksum: ${p.checksum}")
}
}
14 changes: 0 additions & 14 deletions brainfuck/scala-staged/build.sbt

This file was deleted.

1 change: 0 additions & 1 deletion brainfuck/scala-staged/project/build.properties

This file was deleted.

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