Skip to content

Commit 41bcf7b

Browse files
ViralBShahclaude
andauthored
Add Scala benchmarks to CI (#95)
* Add Scala benchmarks to CI and fix chart x-axis labels Modernize the Scala benchmarks from Scala 2.11/Breeze 0.10 to Scala 3.3/Breeze 2.1, fix benchmark names to match the current conventions, and add Scala to the CI pipeline. - Rewrite perf.scala: use correct benchmark names, match iteration counts to Java/C, use while loops for hot paths, inline complex arithmetic in mandelbrot - Update build.sbt to Scala 3.3.4 and Breeze 2.1.0 - Add bench-scala CI job with sbt/setup-sbt action - Move Scala from "Additional languages" to "Languages in CI" in README - Add Scala to Makefile, versions.sh, docs/make.jl, docs/notes.md - Fix chart x-axis: add autoSkip:false so language names always display Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix Breeze Scala 3 compatibility in randmatstat - Import RandBasis for Gaussian distribution - Use explicit [Double] type parameter for DenseMatrix.rand - Replace horzcat/vertcat with manual slice assignment to avoid ambiguous implicit resolution in Scala 3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Filter sbt output in Makefile and remove deprecated showSuccess - Pipe sbt output through grep '^scala,' to avoid sbt launcher messages and netlib warnings polluting the CSV - Redirect sbt stderr to /dev/null - Remove deprecated showSuccess setting that caused lint warning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f717b04 commit 41bcf7b

10 files changed

Lines changed: 265 additions & 229 deletions

File tree

.github/workflows/benchmarks.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,38 @@ jobs:
314314
benchmarks/rust.csv
315315
version.csv
316316
317+
bench-scala:
318+
runs-on: ubuntu-latest
319+
defaults:
320+
run:
321+
shell: bash
322+
steps:
323+
- uses: actions/checkout@v6
324+
with:
325+
persist-credentials: false
326+
- name: "Set up Java"
327+
uses: actions/setup-java@v4
328+
with:
329+
distribution: 'temurin'
330+
java-version: '21'
331+
- name: "Set up sbt"
332+
uses: sbt/setup-sbt@v1
333+
- name: "Set up OpenBLAS"
334+
run: sudo apt-get install -y libopenblas-dev
335+
- name: "Download dependencies and compile"
336+
run: cd scala && sbt --batch compile
337+
- name: "Run benchmark"
338+
run: make benchmarks/scala.csv
339+
- name: "Capture version"
340+
run: bash bin/versions.sh scala > version.csv
341+
- name: "Upload results"
342+
uses: actions/upload-artifact@v4
343+
with:
344+
name: bench-scala
345+
path: |
346+
benchmarks/scala.csv
347+
version.csv
348+
317349
bench-swift:
318350
runs-on: ubuntu-latest
319351
defaults:
@@ -361,6 +393,7 @@ jobs:
361393
- bench-python
362394
- bench-r
363395
- bench-rust
396+
- bench-scala
364397
- bench-swift
365398
defaults:
366399
run:

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ benchmarks/java.csv: java/src/main/java/PerfBLAS.java
9898

9999
benchmarks/scala.csv: scala/src/main/scala/perf.scala scala/build.sbt
100100
cd scala
101-
@for t in $(ITERATIONS); do sbt run; done >../$@
101+
@for t in $(ITERATIONS); do sbt --batch run 2>/dev/null | grep '^scala,'; done >../$@
102102

103103
benchmarks/rust.csv: rust/src/main.rs rust/src/util.rs rust/Cargo.toml
104104
cd rust
@@ -109,8 +109,8 @@ benchmarks/swift.csv: swift/Sources/perf/main.swift swift/Package.swift
109109
swift build -c release -Xlinker -lopenblas
110110
@for t in $(ITERATIONS); do .build/release/perf; done >../$@
111111

112-
LANGUAGES = c fortran go java javascript julia lua mathematica matlab octave python r rust swift
113-
GH_ACTION_LANGUAGES = c fortran go java javascript julia lua octave python r rust swift
112+
LANGUAGES = c fortran go java javascript julia lua mathematica matlab octave python r rust scala swift
113+
GH_ACTION_LANGUAGES = c fortran go java javascript julia lua octave python r rust scala swift
114114

115115
BENCHMARKS = $(foreach lang,$(LANGUAGES),benchmarks/$(lang).csv)
116116
GH_ACTION_BENCHMARKS = $(foreach lang,$(GH_ACTION_LANGUAGES),benchmarks/$(lang).csv)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Running the full suite locally requires:
3737

3838
* GCC and GFortran
3939
* OpenBLAS development libraries (`libopenblas-dev` on Debian/Ubuntu)
40-
* Go, Java (Maven), Node.js, Python 3 (NumPy), R, Rust, Swift, LuaJIT, Octave
40+
* Go, Java (Maven), Node.js, Python 3 (NumPy), R, Rust, Scala (sbt), Swift, LuaJIT, Octave
4141

4242
Individual language benchmarks can be run with, e.g., `make benchmarks/julia.csv`.
4343

@@ -54,10 +54,10 @@ Individual language benchmarks can be run with, e.g., `make benchmarks/julia.csv
5454
* [Python](python/perf.py)
5555
* [R](r/perf.R)
5656
* [Rust](rust/src/main.rs)
57+
* [Scala](scala/src/main/scala/perf.scala)
5758
* [Swift](swift/Sources/perf/main.swift)
5859

5960
## Additional languages (local only)
6061

6162
* [Mathematica](mathematica/perf.nb)
6263
* [Matlab](octave/perf.m)
63-
* [Scala](scala/src/main/scala/perf.scala)

bin/versions.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# User argument declaring what languages to query:
4-
DEFAULT_LANGUAGES="c:fortran:go:java:javascript:julia:lua:mathematica:matlab:octave:python:r:rust"
4+
DEFAULT_LANGUAGES="c:fortran:go:java:javascript:julia:lua:mathematica:matlab:octave:python:r:rust:scala"
55
LANGUAGES=${1:-$DEFAULT_LANGUAGES}
66

77
LANGUAGES=":${LANGUAGES}:"
@@ -72,6 +72,11 @@ if [[ $LANGUAGES == *":rust:"* ]]; then
7272
rustc --version | cut -c 7- | sed 's/ ([0-9a-f]* /<br>(/g'
7373
fi
7474

75+
if [[ $LANGUAGES == *":scala:"* ]]; then
76+
echo -n "scala,"
77+
grep 'scalaVersion' scala/build.sbt | grep -oP '\d+\.\d+\.\d+'
78+
fi
79+
7580
if [[ $LANGUAGES == *":swift:"* ]]; then
7681
echo -n "swift,"
7782
swift --version 2>&1 | head -1 | sed 's/Swift version //' | cut -f1 -d" "

docs/make.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const LANG_LABELS = Dict(
1616
"r" => "R",
1717
"go" => "Go",
1818
"rust" => "Rust",
19+
"scala" => "Scala",
1920
"swift" => "Swift",
2021
)
2122

@@ -182,6 +183,8 @@ function make_chart(benchfile::String)
182183
max: $(length(langs) - 1).5,
183184
ticks: {
184185
stepSize: 1,
186+
autoSkip: false,
187+
maxRotation: 45,
185188
callback: function(value) {
186189
var labels = $labels_json;
187190
return labels[value] || "";

docs/src/notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ matrix multiplication routine for each language. For most compiled
3030
languages this means calling BLAS (via OpenBLAS):
3131

3232
**Using BLAS/optimized libraries:** C, Fortran, Julia, Python (NumPy),
33-
Go (Gonum), Java (jBLAS), Rust (ndarray), R, Octave, Swift (Accelerate)
33+
Go (Gonum), Java (jBLAS), Rust (ndarray), Scala (Breeze), R, Octave, Swift (Accelerate)
3434

3535
**Pure implementation:** JavaScript, LuaJIT
3636

scala/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ lib_managed/
1111
src_managed/
1212
project/boot/
1313
project/plugins/project/
14+
project/target/
1415

1516
# Scala-IDE specific
1617
.scala_dependencies

scala/build.sbt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
// This file was formerly a part of Julia. License is MIT: https://julialang.org/license
22

3-
libraryDependencies ++= Seq(
4-
"org.scalanlp" %% "breeze" % "0.10",
5-
"org.scalanlp" %% "breeze-natives" % "0.10"
6-
)
3+
scalaVersion := "3.3.4"
74

8-
resolvers ++= Seq(
9-
"Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
10-
)
11-
12-
scalaVersion := "2.11.1"
13-
14-
showSuccess := false
5+
libraryDependencies += "org.scalanlp" %% "breeze" % "2.1.0"
156

167
onLoadMessage := ""
178

scala/project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.10.7

0 commit comments

Comments
 (0)