Skip to content

Fix benchmarks and add multiple mini benchmark tests #1690

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 3 commits into from
Jan 11, 2017
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
17 changes: 15 additions & 2 deletions bench/test/dotty/tools/benchmarks/Benchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.scalameter.reporting.RegressionReporter.Tester
import dotty.tools.dotc.CompilerTest

import scala.io.Source
import scala.reflect.io.Directory

// decorator of persitor to expose info for debugging
class DecoratorPersistor(p: Persistor) extends SerializationPersistor {
Expand Down Expand Up @@ -36,7 +37,7 @@ class DecoratorPersistor(p: Persistor) extends SerializationPersistor {
}

object BenchTests extends OnlineRegressionReport {
val outputDir = "./out/"
val outputDir = "../out/"

val compiler = new CompilerTest {
override val defaultOutputDir: String = outputDir
Expand All @@ -45,7 +46,8 @@ object BenchTests extends OnlineRegressionReport {
implicit val defaultOptions = List("-d", outputDir)
val scala2mode = List("-language:Scala2")

val dottyDir = "../compiler/src/dotty/"
val dottyDir = "../compiler/src/dotty/"
val testDir = "../bench/tests/"

val stdlibFiles = Source.fromFile("../compiler/test/dotc/scala-collections.whitelist", "UTF8").getLines()
.map(_.trim) // allow identation
Expand Down Expand Up @@ -80,6 +82,17 @@ object BenchTests extends OnlineRegressionReport {
measure.method("dotty-src") in {
using(Gen.unit("test")) curve "dotty-src" in { r => dotty }
}

val dir = Directory(testDir)
val fileNames = dir.files.toArray.map(_.jfile.getName).filter(name => (name endsWith ".scala"))

for (name <- fileNames) {
measure.method(name) in {
using(Gen.unit("test")) curve "dotty" in { r =>
compiler.compileFile(testDir, name, extension = "")
}
}
}
}

/** workaround to fix problem in ScalaMeter
Expand Down
68 changes: 68 additions & 0 deletions bench/tests/exhaustivity-I.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
abstract sealed trait C
case object C1 extends C
case object C2 extends C
case object C3 extends C
case object C4 extends C
case object C5 extends C
case object C6 extends C
case object C7 extends C
case object C8 extends C
case object C9 extends C
case object C10 extends C
case object C11 extends C
case object C12 extends C
case object C13 extends C
case object C14 extends C
case object C15 extends C
case object C16 extends C
case object C17 extends C
case object C18 extends C
case object C19 extends C
case object C20 extends C
case object C21 extends C
case object C22 extends C
case object C23 extends C
case object C24 extends C
case object C25 extends C
case object C26 extends C
case object C27 extends C
case object C28 extends C
case object C29 extends C
case object C30 extends C

object Test {

def test(c: C): Int = c match {
case C1 => 1
case C2 => 2
case C3 => 3
case C4 => 4
case C5 => 5
case C6 => 6
case C7 => 7
case C8 => 8
case C9 => 9
case C10 => 10
case C11 => 11
case C12 => 12
case C13 => 13
case C14 => 14
case C15 => 15
case C16 => 16
case C17 => 17
case C18 => 18
case C19 => 19
case C20 => 20
case C21 => 21
case C22 => 22
case C23 => 23
case C24 => 24
case C25 => 25
case C26 => 26
case C27 => 27
case C28 => 28
case C29 => 29
case C30 => 30

}
}
20 changes: 20 additions & 0 deletions bench/tests/exhaustivity-S.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

sealed trait O
object A extends O
object B extends O

object Test {

def test(x: O) =
(x, x, x, x, x, x, x, x, x, x, x, x, x, x) match {
case (A, A, _, _, _, _, _, _, _, _, _, _, _, _) => 1
case (_, _, A, A, _, _, _, _, _, _, _, _, _, _) => 2
case (_, _, _, _, A, A, _, _, _, _, _, _, _, _) => 3
case (_, _, _, _, _, _, A, A, _, _, _, _, _, _) => 4
case (_, _, _, _, _, _, _, _, A, A, _, _, _, _) => 5
case (_, _, _, _, _, _, _, _, _, _, A, A, _, _) => 6
case (_, _, _, _, _, _, _, _, _, _, _, _, A, A) => 7
case (B, A, B, A, B, A, B, A, B, A, B, A, B, A) => 8

}
}
28 changes: 28 additions & 0 deletions bench/tests/exhaustivity-T.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

sealed trait O
object A extends O
object B extends O

object Test {

def test(x: O) =
(x, x, x, x, x, x, x, x) match {
case (A, A, A, A, A, A, A, A) => 1
case (B, B, B, B, B, B, B, B) => 2
case (_, A, A, A, A, A, A, A) => 3
case (_, B, B, B, B, B, B, B) => 4
case (_, _, A, A, A, A, A, A) => 5
case (_, _, B, B, B, B, B, B) => 6
case (_, _, _, A, A, A, A, A) => 7
case (_, _, _, B, B, B, B, B) => 8
case (_, _, _, _, A, A, A, A) => 9
case (_, _, _, _, B, B, B, B) => 10
case (_, _, _, _, _, A, A, A) => 11
case (_, _, _, _, _, B, B, B) => 12
case (_, _, _, _, _, _, A, A) => 13
case (_, _, _, _, _, _, B, B) => 14
case (_, _, _, _, _, _, _, A) => 15
case (_, _, _, _, _, _, _, B) => 16

}
}
18 changes: 18 additions & 0 deletions bench/tests/exhaustivity-V.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

sealed trait O
object A extends O
object B extends O

object Test {

def test(x: O) =
(x, x, x, x, x, x, x, x, x, x, x, x, x, x, x) match {
case (A, A, A, A, A, _, _, _, _, _, _, _, _, _, _) => 1
case (B, _, _, _, _, A, A, A, A, _, _, _, _, _, _) => 2
case (_, B, _, _, _, B, _, _, _, A, A, A, _, _, _) => 3
case (_, _, B, _, _, _, B, _, _, B, _, _, A, A, _) => 4
case (_, _, _, B, _, _, _, B, _, _, B, _, B, _, A) => 5
case (_, _, _, _, B, _, _, _, B, _, _, B, _, B, B) => 6

}
}
9 changes: 9 additions & 0 deletions bench/tests/i1535.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Example {
case class C[H, T](h: H, t: T)

type I = Int

val p
: C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,I]]]]]]]]]]]]]]]]]]]]]]]
= C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,1)))))))))))))))))))))))
}
10 changes: 10 additions & 0 deletions bench/tests/i1687.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object O {
def f: String = {
"1" + 1 + "1" + 1 +
"1" + 1 + "1" + 1 +
"1" + 1 + "1" + 1 +
"1" + 1 + "1" + 1 +
"1" + 1 + "1" + 1 +
"1" + 1 + "1" + 1
}
}
9 changes: 9 additions & 0 deletions bench/tests/i490.scala.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait Foo {
def app(x: Object)(y: Object): Object
}

object O {
def main(args: Array[String]): Unit = {
val z: Foo = x => ???
}
}
17 changes: 17 additions & 0 deletions bench/tests/implicit-scope-loop.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
trait Dummy[T]


trait A[T] extends B
trait B extends Dummy[A[Int]]
object B {
implicit def theB: B = new B {}
implicit def theA: A[Int] = new A[Int] {}
}

object Test {
def getB(implicit b: B) = b
def getA[T](implicit a: A[T]) = a

getB
getA
}
16 changes: 16 additions & 0 deletions bench/tests/implicit_cache.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class A
object A {
implicit def theA: A = new A
}
class Foo[T]
object Foo {
implicit def theFoo: Foo[A] = new Foo[A]
}

object Test {
def getFooA(implicit foo: Foo[A]) = foo
def getA(implicit a: A) = a

getFooA
getA
}
2 changes: 1 addition & 1 deletion compiler/test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class tests extends CompilerTest {
Directory(defaultOutputDir + "java").deleteRecursively()
}

@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
@Test def pickle_pickleOK = compileFiles(testsDir + "pickling/", testPickling)
// This directory doesn't exist anymore
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
@Test def pickle_ast = compileDir(dotcDir, "ast", testPickling)
Expand Down