Skip to content

Add cross-compilation support for Scala-2.13.0-M5 #4

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@

An independent set of benchmarks for testing common Scala idioms.

** Running

To run all benchmarks for the default Scala version (2.12):
#+BEGIN_SRC shell
# runs benchmarks according to the rules:
# -t 1 <-- one thread
# -f 1 <-- one forked JVM
# -wi 5 <-- five warmup runs before the actual measuring begins
# -i 5 <-- five actual benchmarking iterations
# .*Bench.* <-- only files matching `Bench` - which is all of them - are included in the run
sbt "jmh:run -t 1 -f 1 -wi 5 -i 5 .*Bench.*"
#+END_SRC

To run all benchmarks for an alternative Scala version:
#+BEGIN_SRC shell
sbt "++2.13.0-M5 jmh:run -t 1 -f 1 -wi 5 -i 5 .*Bench.*"
#+END_SRC

Running all benchmarks can take a long time (i.e. hours). To specify a single `StreamBench` benchmark:
#+BEGIN_SRC shell
sbt "jmh:run -t 1 -f 1 -wi 5 -i 5 .*StreamBench.*"
#+END_SRC

And to do the same for all supported Scala versions:
#+BEGIN_SRC shell
sbt "+ jmh:run -t 1 -f 1 -wi 5 -i 5 .*StreamBench.*"
#+END_SRC

** Results

*** Functional Programming
Expand Down
18 changes: 14 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@ name := """scala-benchmarks"""

version := "1.0.0"

scalaVersion := "2.12.6"
scalaVersion := "2.12.8"

crossScalaVersions := Seq(scalaVersion.value, "2.13.0-M5")

scalacOptions := Seq(
"-opt:l:inline",
"-opt-inline-from:**",
"-deprecation",
"-Ypartial-unification",
"-Ywarn-value-discard",
"-Ywarn-unused-import",
"-Ywarn-unused:imports",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen"
)

Compile / unmanagedSourceDirectories ++= {
val mainSourceDir = baseDirectory.value / "src" / "main" / "scala"
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) =>
Seq(file(mainSourceDir.getPath + "-2.13"))
case _ => Nil
}
}

libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.2.24"
"org.scalaz" %% "scalaz-core" % "7.2.27"
)

/* To run benchmarks:
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.1.4
sbt.version=1.2.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4")
12 changes: 12 additions & 0 deletions src/main/scala-2.13/benchmarks/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package object benchmarks {
// Override references to `Stream` within `package benchmarks` to point to
// `s.c.i.LazyList` instead of `s.c.i.Stream` which was deprecated in Scala
// 2.13.
//
// Note that if for some reason this file is not included during compilation
// (for example, if sbt fails to include the Scala 2.13-specific source
// directory), then the benchmarks will still compile fine, albeit with
// warnings that `Stream` is deprecated.
type Stream[+A] = scala.collection.immutable.LazyList[A]
val Stream = scala.collection.immutable.LazyList
}
1 change: 0 additions & 1 deletion src/main/scala/benchmarks/StreamBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class StreamBench {
str1 = Stream.range(1, 10000)
str2 = Stream.range(10000, 1, -1)
estr1 = EphemeralStream.range(1, 10000)
estr2 = EphemeralStream.fromStream(str2)
}

@Benchmark
Expand Down