aboutsummaryrefslogtreecommitdiff
path: root/tests/run/caseClassHash.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-09-14 17:07:23 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-09-14 17:07:23 +0200
commit12053fa4d55497fc4df06afd67ba3762019969c3 (patch)
tree0cbab1dee0784793d2ab09124a0103412e813072 /tests/run/caseClassHash.scala
parent91f992c8af3e61a76bd862ad43b9abef9a6c3403 (diff)
downloaddotty-12053fa4d55497fc4df06afd67ba3762019969c3.tar.gz
dotty-12053fa4d55497fc4df06afd67ba3762019969c3.tar.bz2
dotty-12053fa4d55497fc4df06afd67ba3762019969c3.zip
Enable more tests that pass
Diffstat (limited to 'tests/run/caseClassHash.scala')
-rw-r--r--tests/run/caseClassHash.scala37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/run/caseClassHash.scala b/tests/run/caseClassHash.scala
new file mode 100644
index 000000000..c5cb09c35
--- /dev/null
+++ b/tests/run/caseClassHash.scala
@@ -0,0 +1,37 @@
+case class Foo[T](a: Boolean, b: Byte, c: Short, d: Char, e: Int, f: Long, g: Double, h: Float, i: AnyRef, j: T) { }
+
+object Test {
+ def mkFoo[T](x: T) = Foo[T](true, -1, -1, 100, -5, -10, 500d, 500f, Nil, x)
+
+ def main(args: Array[String]): Unit = {
+ val foo1 = mkFoo[Double](5.0d)
+ val foo2 = mkFoo[Long](5l)
+
+ List(foo1, foo2, foo1.##, foo2.##, foo1 == foo2) foreach println
+
+ println("## method 1: " + foo1.##)
+ println("## method 2: " + foo2.##)
+ println(" Murmur 1: " + scala.util.hashing.MurmurHash3.productHash(foo1))
+ println(" Murmur 2: " + scala.util.hashing.MurmurHash3.productHash(foo2))
+ }
+}
+
+object Timing {
+ var hash = 0
+ def mkFoo(i: Int) = Foo(i % 2 == 0, i.toByte, i.toShort, i.toChar, i, i, 1.1, 1.1f, this, this)
+
+ def main(args: Array[String]): Unit = {
+ val reps = if (args.isEmpty) 100000000 else args(0).toInt
+ val start = System.nanoTime
+
+ println("Warmup.")
+ 1 to 10000 foreach mkFoo
+
+ hash = 0
+ 1 to reps foreach (i => hash += mkFoo(i).##)
+
+ val end = System.nanoTime
+ println("hash = " + hash)
+ println("Elapsed: " + ((end - start) / 1e6) + " ms.")
+ }
+}