From 623a1d43155823cc7506c3223405bb68f459fd50 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Thu, 13 Apr 2017 17:38:34 +0200 Subject: Fix #2220: disable benchmarks, set run timeout to 30 seconds --- tests/run/t2417.check | 12 --- tests/run/t2417.scala | 77 ------------------- tests/run/t3242.scala | 52 ------------- tests/run/t3989.scala | 17 ----- tests/run/t4459.scala | 12 --- tests/run/t6253a.scala | 64 ---------------- tests/run/t6253b.scala | 62 --------------- tests/run/t6253c.scala | 63 --------------- tests/run/t6853.scala | 18 ----- tests/run/vector1.scala | 199 ------------------------------------------------ 10 files changed, 576 deletions(-) delete mode 100644 tests/run/t2417.check delete mode 100644 tests/run/t2417.scala delete mode 100644 tests/run/t3242.scala delete mode 100644 tests/run/t3989.scala delete mode 100644 tests/run/t4459.scala delete mode 100644 tests/run/t6253a.scala delete mode 100644 tests/run/t6253b.scala delete mode 100644 tests/run/t6253c.scala delete mode 100644 tests/run/t6853.scala delete mode 100644 tests/run/vector1.scala (limited to 'tests/run') diff --git a/tests/run/t2417.check b/tests/run/t2417.check deleted file mode 100644 index 36c954be2..000000000 --- a/tests/run/t2417.check +++ /dev/null @@ -1,12 +0,0 @@ -testing small Map that doesn't promote to HashMap... - -testing single-threaded HashMap use... - -testing HashMap.size from multiple threads... - -testing small Set that doesn't promote to HashSet... - -testing single-threaded HashSet use... - -testing HashSet.size from multiple threads... - diff --git a/tests/run/t2417.scala b/tests/run/t2417.scala deleted file mode 100644 index 80105f72b..000000000 --- a/tests/run/t2417.scala +++ /dev/null @@ -1,77 +0,0 @@ -// #2417 -object Test { - - def parallel(numThreads: Int)(block: => Unit): Unit = { - var failure: Throwable = null - val threads = Array.tabulate(numThreads)(i => new Thread { - override def run: Unit = { - try { - block - } catch { - case x: Throwable => failure = x - } - } - }) - for (t <- threads) t.start - for (t <- threads) t.join - if (failure != null) println("FAILURE: " + failure) - } - - def testSet(initialSize: Int, numThreads: Int, passes: Int): Unit = { - val orig = Set.empty ++ (1 to initialSize) - parallel(numThreads) { - for (pass <- 0 until passes) { - var s = orig - for (e <- (initialSize to 1 by -1)) { - s -= e - val obs = s.size - if (obs != e - 1) { - throw new Exception("removed e=" + e + ", size was " + obs + ", s=" + s) - } - } - } - } - } - - def testMap(initialSize: Int, numThreads: Int, passes: Int): Unit = { - val orig = Map.empty ++ ((1 to initialSize) map ((_,"v"))) - parallel(numThreads) { - for (pass <- 0 until passes) { - var m = orig - for (e <- (initialSize to 1 by -1)) { - m -= e - val obs = m.size - if (obs != e - 1) { - throw new Exception("removed e=" + e + ", size was " + obs + ", m=" + m) - } - } - } - } - } - - def main(args: Array[String]): Unit = { - println("testing small Map that doesn't promote to HashMap...") - testMap(4, 2, 1000000) - println() - - println("testing single-threaded HashMap use...") - testMap(5, 1, 1000000) - println() - - println("testing HashMap.size from multiple threads...") - testMap(5, 2, 1000000) - println() - - println("testing small Set that doesn't promote to HashSet...") - testSet(4, 2, 1000000) - println() - - println("testing single-threaded HashSet use...") - testSet(5, 1, 1000000) - println() - - println("testing HashSet.size from multiple threads...") - testSet(5, 2, 1000000) - println() - } -} diff --git a/tests/run/t3242.scala b/tests/run/t3242.scala deleted file mode 100644 index 6a8ecd7a2..000000000 --- a/tests/run/t3242.scala +++ /dev/null @@ -1,52 +0,0 @@ - -import scala.language.{ higherKinds } - -object Test { - - def benchmarkA(num: Int): Unit = { - - type A = Int - - def updateM[M[_]](ms: M[A], update: (M[A], A)=>M[A]): M[A] = { - var is = ms - for (i <- 0 until num) is = update(is, i) - is - } - - // - def vectorAppend: Vector[A] = updateM[Vector](Vector(), (as, a)=>{ - val v = (as :+ a) - //println("==>append: i: "+i1+", v: "+v) - v - }) - // this will crash, Vector bug! - def vectorRemove(vec: Vector[A]): Vector[A] = updateM[Vector](vec, (as, a)=>{ - val v = (as filterNot{ _ == a}) - //val v = (is filter{ _ != i}) - //println("==>remove: i: "+a) - v - }) - - val ct = vectorAppend - println(" append [num: "+num+"] vec") - vectorRemove(ct) - println(" remove [num: "+num+"] vec") - } // BenchmarkA - - def comparison(num: Int): Unit = { - for (i <- 1 until 5) benchmarkA(num*i) - println(">> comparison done, num: "+num); - } - - def main(args: Array[String]): Unit = { - try { - //createBenchmarkA(23).testRun - - comparison(200) // OK - comparison(2000) // this will crach - - } catch { - case e: Exception => e.printStackTrace() - } - } -} diff --git a/tests/run/t3989.scala b/tests/run/t3989.scala deleted file mode 100644 index 896283f19..000000000 --- a/tests/run/t3989.scala +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -class Foo{ override def equals(o: Any) = false; override def hashCode = 1} - -// should not result in a stack overflow -object Test { - def main(args: Array[String]): Unit = { - import collection.immutable.HashMap - var m = Map[Foo, Int]() - for (i <- 1 to 30000) m += (new Foo) -> i - assert(m.size == 30000) - m.toString - } -} diff --git a/tests/run/t4459.scala b/tests/run/t4459.scala deleted file mode 100644 index ea3b7420b..000000000 --- a/tests/run/t4459.scala +++ /dev/null @@ -1,12 +0,0 @@ -import collection._ - -object Test { - def main(args: Array[String]): Unit = { - for (i <- 0 until 2000) { - foo((0 until 10000).toSeq.par) - } - } - - def foo(arg: GenSeq[_]): String = arg.map(x => x).mkString(",") -} - diff --git a/tests/run/t6253a.scala b/tests/run/t6253a.scala deleted file mode 100644 index c2db1f5af..000000000 --- a/tests/run/t6253a.scala +++ /dev/null @@ -1,64 +0,0 @@ -import scala.collection.immutable.HashSet - -object Test extends dotty.runtime.LegacyApp { - - var hashCount = 0 - - /** - * A key that produces lots of hash collisions, to exercise the part of the code that deals with those - */ - case class Collision(value: Int) { - - override def hashCode = { - // we do not check hash counts for Collision keys because ListSet.++ uses a mutable hashset internally, - // so when we have hash collisions, union will call key.hashCode. - // hashCount += 1 - value / 5 - } - } - - /** - * A key that is identical to int other than that it counts hashCode invocations - */ - case class HashCounter(value: Int) { - - override def hashCode = { - hashCount += 1 - value - } - } - - def testUnion[T](sizes: Seq[Int], offsets: Seq[Double], keyType: String, mkKey: Int => T): Unit = { - for { - i <- sizes - o <- offsets - } { - val e = HashSet.empty[T] - val j = (i * o).toInt - // create two sets of size i with overlap o - val a = e ++ (0 until i).map(mkKey) - require(a.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val b = e ++ (j until (i + j)).map(mkKey) - require(b.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val as = e ++ (0 until j).map(mkKey) - require(as.size == j, s"Building HashSet of size $j failed. Key type $keyType.") - val hashCount0 = hashCount - val u = a union b - require(hashCount == hashCount0, s"key.hashCode should not be called, but has been called ${hashCount - hashCount0} times. Key type $keyType.") - require(u == (a union scala.collection.mutable.HashSet(b.toSeq: _*)), s"Operation must still work for other sets!") - require(u.size == i + j, s"Expected size ${i+j}. Real size ${u.size}. Key type $keyType.") - for (x <- 0 until i + j) - require(u.contains(mkKey(x)), s"Key type $keyType. Set (0 until ${i + j}) should contain $x but does not.") - val a_as = a union as - val as_a = as union a - require((a_as eq a) || (a_as eq as), s"No structural sharing in a union as. Key type $keyType, a=(0 until $i) as=(0 until $j)") - require((as_a eq a) || (as_a eq as), s"No structural sharing in as union a. Key type $keyType, a=(0 until $i) as=(0 until $j)") - } - } - - val sizes = Seq(1, 10, 100, 1000, 10000, 100000) - val offsets = Seq(0.0, 0.25, 0.5, 0.75, 1.0) - testUnion(sizes, offsets, "int", identity[Int]) - testUnion(sizes, offsets, "hashcounter", HashCounter.apply) - testUnion(sizes, offsets, "collision", Collision.apply) -} diff --git a/tests/run/t6253b.scala b/tests/run/t6253b.scala deleted file mode 100644 index c049aea7f..000000000 --- a/tests/run/t6253b.scala +++ /dev/null @@ -1,62 +0,0 @@ -import scala.collection.immutable.HashSet - -object Test extends dotty.runtime.LegacyApp { - - var hashCount = 0 - - /** - * A key that produces lots of hash collisions, to exercise the part of the code that deals with those - */ - case class Collision(value: Int) { - - override def hashCode = { - hashCount += 1 - value / 5 - } - } - - /** - * A key that is identical to int other than that it counts hashCode invocations - */ - case class HashCounter(value: Int) { - - override def hashCode = { - hashCount += 1 - value - } - } - - def testIntersect[T](sizes: Seq[Int], offsets: Seq[Double], keyType: String, mkKey: Int => T): Unit = { - for { - i <- sizes - o <- offsets - } { - val e = HashSet.empty[T] - val j = (i * o).toInt - // create two sets of size i with overlap o - val a = e ++ (0 until i).map(mkKey) - require(a.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val b = e ++ (j until (i + j)).map(mkKey) - require(b.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val as = e ++ (0 until j).map(mkKey) - require(as.size == j, s"Building HashSet of size $j failed. Key type $keyType.") - val hashCount0 = hashCount - val u = a intersect b - require(hashCount == hashCount0, s"key.hashCode should not be called, but has been called ${hashCount - hashCount0} times. Key type $keyType.") - require(u == (a intersect scala.collection.mutable.HashSet(b.toSeq: _*)), s"Operation must still work for other sets!") - require(u.size == i - j, s"Expected size ${i + j}. Real size ${u.size}. Key type $keyType.") - for (x <- j until i) - require(u.contains(mkKey(x)), s"Key type $keyType. Set (0 until ${i + j}) should contain $x but does not.") - val a_as = a intersect as - val as_a = as intersect a - require((a_as eq as) || (a_as eq a), s"No structural sharing in a intersect as. Key type $keyType, a=(0 until $i) as=(0 until $j)") - require((as_a eq as) || (as_a eq a), s"No structural sharing in as intersect a. Key type $keyType, a=(0 until $i) as=(0 until $j)") - } - } - - val sizes = Seq(1, 10, 100, 1000, 10000, 100000) - val offsets = Seq(0.0, 0.25, 0.5, 0.75, 1.0) - testIntersect(sizes, offsets, "int", identity[Int]) - testIntersect(sizes, offsets, "hashcounter", HashCounter.apply) - testIntersect(sizes, offsets, "collision", Collision.apply) -} diff --git a/tests/run/t6253c.scala b/tests/run/t6253c.scala deleted file mode 100644 index 39c3a5b17..000000000 --- a/tests/run/t6253c.scala +++ /dev/null @@ -1,63 +0,0 @@ -import scala.collection.immutable.HashSet - -object Test extends dotty.runtime.LegacyApp { - - var hashCount = 0 - - /** - * A key that produces lots of hash collisions, to exercise the part of the code that deals with those - */ - case class Collision(value: Int) { - - override def hashCode = { - hashCount += 1 - value / 5 - } - } - - /** - * A key that is identical to int other than that it counts hashCode invocations - */ - case class HashCounter(value: Int) { - - override def hashCode = { - hashCount += 1 - value - } - } - - def testDiff[T](sizes: Seq[Int], offsets: Seq[Double], keyType: String, mkKey: Int => T): Unit = { - for { - i <- sizes - o <- offsets - } { - val e = HashSet.empty[T] - val j = (i * o).toInt - // create two sets of size i with overlap o - val a = e ++ (0 until i).map(mkKey) - require(a.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val b = e ++ (j until (i + j)).map(mkKey) - require(b.size == i, s"Building HashSet of size $i failed. Key type $keyType.") - val as = e ++ (0 until j).map(mkKey) - require(as.size == j, s"Building HashSet of size $j failed. Key type $keyType.") - val hashCount0 = hashCount - val u = a diff b - require(hashCount == hashCount0, s"key.hashCode should not be called, but has been called ${hashCount - hashCount0} times. Key type $keyType.") - require(u == (a diff scala.collection.mutable.HashSet(b.toSeq: _*)), s"Operation must still work for other sets!") - require(u.size == j, s"Expected size $j. Real size ${u.size}. Key type $keyType.") - for (x <- 0 until j) - require(u.contains(mkKey(x)), s"Key type $keyType. Set (0 until ${i + j}) should contain $x but does not.") - require((as intersect b).isEmpty) - val b_as = b diff as - val as_b = as diff b - require((b_as eq b) || (b_as eq as), s"No structural sharing in b diff as. Key type $keyType, b=($j until ${i + j}) as=(0 until $j)") - require((as_b eq b) || (as_b eq as), s"No structural sharing in as diff b. Key type $keyType, b=($j until ${i + j}) as=(0 until $j)") - } - } - - val sizes = Seq(1, 10, 100, 1000, 10000, 100000) - val offsets = Seq(0.0, 0.25, 0.5, 0.75, 1.0) - testDiff(sizes, offsets, "int", identity[Int]) - testDiff(sizes, offsets, "hashCounter", HashCounter.apply) - testDiff(sizes, offsets, "collision", Collision.apply) -} diff --git a/tests/run/t6853.scala b/tests/run/t6853.scala deleted file mode 100644 index 352375c99..000000000 --- a/tests/run/t6853.scala +++ /dev/null @@ -1,18 +0,0 @@ -// Test cases: the only place we can cut and paste without crying -// ourself to sleep. -object Test { - - def main(args: Array[String]): Unit = { - // First testing the basic operations - val m = collection.mutable.ListMap[String, Int]() - var i = 0 - while(i < 2) { m += ("foo" + i) -> i; i = i+1} - assert(m == Map("foo1"->1,"foo0"->0)) - m-= "foo0" - assert(m == Map("foo1"->1)) - // Now checking if it scales as described in SI-6853 - i = 0 - while(i < 80000) { m += ("foo" + i) -> i; i = i+1} - assert(m.size == 80000) - } -} diff --git a/tests/run/vector1.scala b/tests/run/vector1.scala deleted file mode 100644 index d53618396..000000000 --- a/tests/run/vector1.scala +++ /dev/null @@ -1,199 +0,0 @@ -// testing the impl from the scala library -//package test5 - -import scala.collection._ -import scala.collection.immutable._ - -import scala.collection.generic._ -import scala.collection.mutable.Builder - - -object Test { - - def vector(label: String, n: Int): Vector[String] = { - val a = new VectorBuilder[String] - for (i <- 0 until n) - a += (label + i) - - val res = a.result - assertVector(res, label, 0, n) - } - - def vectorForward(label: String, n: Int): Vector[String] = { - var a: Vector[String] = Vector.empty - for (i <- 0 until n) - a = a :+ (label + i) - - assertVector(a, label, 0, n) - } - - def vectorBackward(label: String, n: Int): Vector[String] = { - var a: Vector[String] = Vector.empty - for (i <- 0 until n) - a = (label + (n-1-i)) +: a - - assertVector(a, label, 0, n) - } - - def assertVector[V](a: Vector[V], label: String, start: Int, end: Int) = { - assertVectorIndexed(a, label, start, end) - assertVectorIterated(a, label, start, end) - } - - def assertVectorIndexed[V](a: Vector[V], label: String, start: Int, end: Int) = { - val res = a - assert(res.length == (end-start), res.length+"!="+(end-start)+" ("+res+")") - for (i <- start until end) { - assert(res(i) == (label + i), ""+res(i)+"!="+(label + i)) - } - res - } - - def assertVectorIterated[V](a: Vector[V], label: String, start: Int, end: Int) = { - val res = a - assert(res.length == (end-start), res.length+"!="+(end-start)+" ("+res+")") - var i = start - var it = res.iterator - while(it.hasNext) { - val x = it.next() - assert(x == (label + i), x.toString+"!="+(label + i)) - i += 1 - } - assert(i == end) - res - } - - - - def test1() = { - println("===== test1 =====") - - val N = 150000 - val a = vector("a", N) - val b = vectorForward("b", N) - val c = vectorBackward("b", N) - - () -// //println(a) - } - - def test2() = { - println("===== test2 =====") - - var a: Vector[String] = Vector.empty - - val rand = new java.util.Random - - val N = 150000 - var min = N/2//rand.nextInt(N) - var max = min - - val chunkLimit = 11 - - def nextChunkSize = 3 //rand.nextInt(chunkLimit) - - def seqBack() = for (i <- 0 until Math.min(nextChunkSize, N-max)) { a = a :+ ("a"+max); max += 1 } - def seqFront() = for (i <- 0 until Math.min(nextChunkSize, min)) { min -= 1; a = ("a"+min) +: a } - - try { - - while (min > 0 || max < N) { - seqFront() - seqBack() - } - } catch { - case ex: Throwable => - //println("----------------") - //a.debug - throw ex - } - - assertVector(a, "a", 0, N) - } - - - - def test3() = { - println("===== test3 =====") - - val N = 150000 - val a = vector("a", N) - - val pos = scala.util.Random.shuffle(scala.collection.mutable.WrappedArray.make[Int](Array.tabulate[Int](N)(i => i))) - - var b = a - - { - var i = 0 - while (i < N) { - b = b.updated(pos(i), "b"+(pos(i))) - i += 1 - } - - assertVector(b, "b", 0, N) - } - -// //println(a) - } - - def test4() = { - println("===== test4 =====") - - val N = 150000 - val a = vectorForward("a", N) - - { - var i = 0 - var it = a - while (i < N) { - assert(it.length == (N-i), it.length+" items at iteration "+i) - val x = it(0) - val y = it(N-i-1) - assert(x == "a"+i, x+"!=a"+i) - assert(y == "a"+(N-1), y+"!=a"+(N-1)) - it = it.drop(1) - i += 1 - } - assert(it.length == 0) - } - -// //println(a) - } - - def test5() = { - println("===== test5 =====") - - val N = 150000 - val a = vectorBackward("a", N) - - { - var i = 0 - var it = a - while (i < N) { - assert(it.length == (N-i), it.length+" items at iteration "+i) - val x = it(0) - val y = it(N-i-1) -// println("x " + x + "/" + i) -// println("y " + y) - assert(x == "a0", x+"!=a0") - assert(y == "a"+(N-i-1), y+"!=a"+(N-i-1)) - it = it.dropRight(1) - i += 1 - } - assert(it.length == 0) - } - } - - def main(args: Array[String]) = { - - test1() - test2() - test3() - test4() - test5() - - println("done") - } - -} - -- cgit v1.2.3