diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t2849.scala | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/files/run/t2849.scala b/test/files/run/t2849.scala index 68094de736..cadf605ae0 100644 --- a/test/files/run/t2849.scala +++ b/test/files/run/t2849.scala @@ -1,11 +1,6 @@ - - - import scala.collection.immutable.SortedSet import scala.collection.immutable.TreeSet - - object Test { def main(args: Array[String]) { @@ -13,15 +8,22 @@ object Test { similarExample } + //def freeMBytes = Runtime.getRuntime.freeMemory / 1048576 + def totalMBytes = Runtime.getRuntime.totalMemory / 1048576 + + val N = if (totalMBytes > 1000) 10000 else 4000 + val M = N / 10 + def ticketExample { var big = 100000 var aSortedSet: SortedSet[Int] = TreeSet(big) - for (i <- 1 until 10000) { + for (i <- 1 until N) { aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) - big = big - 1 - if (i % 1000 == 0) { + big -= 1 + if (i % M == 0) { + //println("big: "+big+", free memory: "+freeMBytes) aSortedSet.until(i) } } @@ -32,10 +34,10 @@ object Test { var aSortedSet: SortedSet[Int] = TreeSet(big) - for (i <- 1 until 10000) { + for (i <- 1 until N) { aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big - big = big - 1 - if (i % 1000 == 0) { + big -= 1 + if (i % M == 0) { aSortedSet.until(i) } } |