aboutsummaryrefslogtreecommitdiff
path: root/tests/disabled/long-running/t2417.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-04-13 19:21:08 +0200
committerGitHub <noreply@github.com>2017-04-13 19:21:08 +0200
commit975f7efab69e8e5a23db665f33dceecb0bf6ceaa (patch)
treeda35c6ff938655ab93c791980ef98d4ae8cb4cca /tests/disabled/long-running/t2417.scala
parent889ed89312cbe70040df92e84432853d38906308 (diff)
parent623a1d43155823cc7506c3223405bb68f459fd50 (diff)
downloaddotty-975f7efab69e8e5a23db665f33dceecb0bf6ceaa.tar.gz
dotty-975f7efab69e8e5a23db665f33dceecb0bf6ceaa.tar.bz2
dotty-975f7efab69e8e5a23db665f33dceecb0bf6ceaa.zip
Merge pull request #2251 from dotty-staging/fix-#2220
Fix #2220: disable benchmarks, set run timeout to 30 seconds
Diffstat (limited to 'tests/disabled/long-running/t2417.scala')
-rw-r--r--tests/disabled/long-running/t2417.scala77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/disabled/long-running/t2417.scala b/tests/disabled/long-running/t2417.scala
new file mode 100644
index 000000000..80105f72b
--- /dev/null
+++ b/tests/disabled/long-running/t2417.scala
@@ -0,0 +1,77 @@
+// #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()
+ }
+}