Skip to content

Make benchmarks work again and simplify benchmarking procedure #68

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
Apr 12, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
/.settings
/.target
/bin
benchmark/JmhBench.scala
6 changes: 2 additions & 4 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ Because the benchmarking is **very computationally expensive** it should be done

## Code generation step

1. Run `sbt console`

2. If the `JmhBench.scala` file already exists, delete it.
1. Make sure the parent project has been built by running `sbt package` in it.

3. Enter `bench.codegen.Generate.jmhBench()` to generate the `JmhBench.scala` file.
2. `cd` to the benchmark project and run `sbt generateJmh`

## Benchmarking step

Expand Down
11 changes: 8 additions & 3 deletions benchmark/build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
enablePlugins(JmhPlugin)

val generateJmh = TaskKey[Unit]("generateJmh", "Generates JMH benchmark sources.")

lazy val root = (project in file(".")).settings(
name := "java8-compat-bench",
scalaVersion := "2.11.7",
crossScalaVersions := List("2.11.7" /* TODO, "2.12.0-M3"*/),
scalaVersion := "2.11.8",
crossScalaVersions := List("2.11.8" /* TODO, "2.12.0-M4"*/),
organization := "org.scala-lang.modules",
version := "0.6.0-SNAPSHOT",
unmanagedJars in Compile ++= Seq(baseDirectory.value / "../target/scala-2.11/scala-java8-compat_2.11-0.6.0-SNAPSHOT.jar")
unmanagedJars in Compile ++= Seq(baseDirectory.value / "../target/scala-2.11/scala-java8-compat_2.11-0.8.0-SNAPSHOT.jar"),
// This would be nicer but sbt-jmh doesn't like it:
//unmanagedClasspath in Compile += Attributed.blank(baseDirectory.value / "../target/scala-2.11/classes"),
generateJmh := (runMain in Compile).toTask(" bench.codegen.GenJmhBench").value
)
2 changes: 1 addition & 1 deletion benchmark/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.5")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.6")
8 changes: 8 additions & 0 deletions benchmark/src/main/scala/bench/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,11 @@ object Generator {
}
}
}

object GenJmhBench {
def main(args: Array[String]): Unit = {
val f = new java.io.File("JmhBench.scala")
f.delete()
Generator.jmhBench(f)
}
}
32 changes: 16 additions & 16 deletions benchmark/src/main/scala/bench/CollectionSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ package object generate {
}

object Pstep {
def i[CC](cc: CC)(implicit steppize: CC => MakesIntStepper): IntStepper =
def i[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper with EfficientSubstep]): IntStepper =
steppize(cc).stepper
def s[CC](cc: CC)(implicit steppize: CC => MakesAnyStepper[String]): AnyStepper[String] =
def s[CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[String] with EfficientSubstep]): AnyStepper[String] =
steppize(cc).stepper
}

object Sstep {
def i[CC](cc: CC)(implicit steppize: CC => MakesIntSeqStepper): IntStepper =
def i[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper]): IntStepper =
steppize(cc).stepper
def s[CC](cc: CC)(implicit steppize: CC => MakesAnySeqStepper[String]): AnyStepper[String] =
def s[CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[String]]): AnyStepper[String] =
steppize(cc).stepper
}

object PsStream {
def i[CC](cc: CC)(implicit steppize: CC => MakesIntStepper): IntStream =
def i[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper with EfficientSubstep]): IntStream =
steppize(cc).stepper.parStream
def s[CC](cc: CC)(implicit steppize: CC => MakesAnyStepper[String]): Stream[String] =
def s[CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[String] with EfficientSubstep]): Stream[String] =
steppize(cc).stepper.parStream
}

object SsStream {
def i[CC](cc: CC)(implicit steppize: CC => MakesIntSeqStepper): IntStream =
def i[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper]): IntStream =
steppize(cc).stepper.seqStream
def s[CC](cc: CC)(implicit steppize: CC => MakesAnySeqStepper[String]): Stream[String] =
def s[CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[String]]): Stream[String] =
steppize(cc).stepper.seqStream
}

Expand Down Expand Up @@ -78,14 +78,14 @@ package object generate {
// Iterator
def iI(j: Int)(implicit x: CC[Int] => Iterator[Int]) = x(cI(j))
// Steppers (second letter--s = sequential, p = parallel)
def tsI(j: Int)(implicit x: CC[Int] => MakesIntSeqStepper) = Sstep i cI(j)
def tpI(j: Int)(implicit x: CC[Int] => MakesIntStepper) = Pstep i cI(j)
def tsI(j: Int)(implicit x: CC[Int] => MakesStepper[IntStepper]) = Sstep i cI(j)
def tpI(j: Int)(implicit x: CC[Int] => MakesStepper[IntStepper with EfficientSubstep]) = Pstep i cI(j)
// Streams
def ssI(j: Int)(implicit x: CC[Int] => MakesSequentialStream[java.lang.Integer, IntStream]) = Sstream i cI(j)
def spI(j: Int)(implicit x: CC[Int] => MakesParallelStream[java.lang.Integer, IntStream]) = Pstream i cI(j)
// Streams via steppers
def zsI(j: Int)(implicit x: CC[Int] => MakesIntSeqStepper) = SsStream i cI(j)
def zpI(j: Int)(implicit x: CC[Int] => MakesIntStepper) = PsStream i cI(j)
def zsI(j: Int)(implicit x: CC[Int] => MakesStepper[IntStepper]) = SsStream i cI(j)
def zpI(j: Int)(implicit x: CC[Int] => MakesStepper[IntStepper with EfficientSubstep]) = PsStream i cI(j)
}

trait StringThingsOf[CC[_]] extends GenThingsOf[CC] {
Expand All @@ -95,14 +95,14 @@ package object generate {
// Iterator
def iS(j: Int)(implicit x: CC[String] => Iterator[String]) = x(cS(j))
// Steppers (second letter--s = sequential, p = parallel)
def tsS(j: Int)(implicit x: CC[String] => MakesAnySeqStepper[String]) = Sstep s cS(j)
def tpS(j: Int)(implicit x: CC[String] => MakesAnyStepper[String]) = Pstep s cS(j)
def tsS(j: Int)(implicit x: CC[String] => MakesStepper[AnyStepper[String]]) = Sstep s cS(j)
def tpS(j: Int)(implicit x: CC[String] => MakesStepper[AnyStepper[String] with EfficientSubstep]) = Pstep s cS(j)
// Streams
def ssS(j: Int)(implicit x: CC[String] => MakesSequentialStream[String, Stream[String]]) = Sstream s cS(j)
def spS(j: Int)(implicit x: CC[String] => MakesParallelStream[String, Stream[String]]) = Pstream s cS(j)
// Streams via steppers
def zsS(j: Int)(implicit x: CC[String] => MakesAnySeqStepper[String]) = SsStream s cS(j)
def zpS(j: Int)(implicit x: CC[String] => MakesAnyStepper[String]) = PsStream s cS(j)
def zsS(j: Int)(implicit x: CC[String] => MakesStepper[AnyStepper[String]]) = SsStream s cS(j)
def zpS(j: Int)(implicit x: CC[String] => MakesStepper[AnyStepper[String] with EfficientSubstep]) = PsStream s cS(j)
}

trait ThingsOf[CC[_]] extends IntThingsOf[CC] with StringThingsOf[CC] {}
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ lazy val root = (project in file(".")).
"""|import scala.concurrent._
|import ExecutionContext.Implicits.global
|import java.util.concurrent.{CompletionStage,CompletableFuture}
|import scala.compat.java8.FutureConverter._
|import scala.compat.java8.FutureConverters._
|""".stripMargin
)