diff options
author | Dmitry Petrashko <dark@d-d.me> | 2017-01-11 17:07:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-11 17:07:02 +0100 |
commit | 8b44b6c1fb0f03a555834d189b98ef30091153fe (patch) | |
tree | a5d030608d8751bdcf583076ff081d70eb87adaa | |
parent | e9165e46e24370e9e5dcccf2c49470ab00e30507 (diff) | |
parent | 157481b24e00c87ba3d44a28dd07c70c28001f0e (diff) | |
download | dotty-8b44b6c1fb0f03a555834d189b98ef30091153fe.tar.gz dotty-8b44b6c1fb0f03a555834d189b98ef30091153fe.tar.bz2 dotty-8b44b6c1fb0f03a555834d189b98ef30091153fe.zip |
Merge pull request #1690 from dotty-staging/bench
Fix benchmarks and add multiple mini benchmark tests
-rw-r--r-- | bench/test/dotty/tools/benchmarks/Benchmarks.scala | 17 | ||||
-rw-r--r-- | bench/tests/exhaustivity-I.scala | 68 | ||||
-rw-r--r-- | bench/tests/exhaustivity-S.scala | 20 | ||||
-rw-r--r-- | bench/tests/exhaustivity-T.scala | 28 | ||||
-rw-r--r-- | bench/tests/exhaustivity-V.scala | 18 | ||||
-rw-r--r-- | bench/tests/i1535.scala | 9 | ||||
-rw-r--r-- | bench/tests/i1687.scala | 10 | ||||
-rw-r--r-- | bench/tests/i490.scala.ignore | 9 | ||||
-rw-r--r-- | bench/tests/implicit-scope-loop.scala | 17 | ||||
-rw-r--r-- | bench/tests/implicit_cache.scala | 16 | ||||
-rw-r--r-- | compiler/test/dotc/tests.scala | 2 |
11 files changed, 211 insertions, 3 deletions
diff --git a/bench/test/dotty/tools/benchmarks/Benchmarks.scala b/bench/test/dotty/tools/benchmarks/Benchmarks.scala index fe5517ad9..dc2d65528 100644 --- a/bench/test/dotty/tools/benchmarks/Benchmarks.scala +++ b/bench/test/dotty/tools/benchmarks/Benchmarks.scala @@ -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 { @@ -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 @@ -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 @@ -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 diff --git a/bench/tests/exhaustivity-I.scala b/bench/tests/exhaustivity-I.scala new file mode 100644 index 000000000..cb13893c8 --- /dev/null +++ b/bench/tests/exhaustivity-I.scala @@ -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 + + } +} diff --git a/bench/tests/exhaustivity-S.scala b/bench/tests/exhaustivity-S.scala new file mode 100644 index 000000000..ba4fef3fd --- /dev/null +++ b/bench/tests/exhaustivity-S.scala @@ -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 + + } +} diff --git a/bench/tests/exhaustivity-T.scala b/bench/tests/exhaustivity-T.scala new file mode 100644 index 000000000..4d094758a --- /dev/null +++ b/bench/tests/exhaustivity-T.scala @@ -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 + + } +} diff --git a/bench/tests/exhaustivity-V.scala b/bench/tests/exhaustivity-V.scala new file mode 100644 index 000000000..be84934d3 --- /dev/null +++ b/bench/tests/exhaustivity-V.scala @@ -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 + + } +} diff --git a/bench/tests/i1535.scala b/bench/tests/i1535.scala new file mode 100644 index 000000000..0433e3ab2 --- /dev/null +++ b/bench/tests/i1535.scala @@ -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))))))))))))))))))))))) +}
\ No newline at end of file diff --git a/bench/tests/i1687.scala b/bench/tests/i1687.scala new file mode 100644 index 000000000..7da9d2824 --- /dev/null +++ b/bench/tests/i1687.scala @@ -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 + } +}
\ No newline at end of file diff --git a/bench/tests/i490.scala.ignore b/bench/tests/i490.scala.ignore new file mode 100644 index 000000000..3758d2917 --- /dev/null +++ b/bench/tests/i490.scala.ignore @@ -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 => ??? + } +} diff --git a/bench/tests/implicit-scope-loop.scala b/bench/tests/implicit-scope-loop.scala new file mode 100644 index 000000000..162f1a52c --- /dev/null +++ b/bench/tests/implicit-scope-loop.scala @@ -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 +}
\ No newline at end of file diff --git a/bench/tests/implicit_cache.scala b/bench/tests/implicit_cache.scala new file mode 100644 index 000000000..d124876e0 --- /dev/null +++ b/bench/tests/implicit_cache.scala @@ -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 +} diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala index fd8b005a9..a7961d937 100644 --- a/compiler/test/dotc/tests.scala +++ b/compiler/test/dotc/tests.scala @@ -107,7 +107,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) |