Program to manually test GCMonitor

This commit is contained in:
Naftoli Gugenheim 2020-11-12 02:36:58 -05:00
parent 427966a2bc
commit af7346f565
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package sbt.internal
import sbt.internal.util.ConsoleLogger
import scala.concurrent.duration._
import scala.util.Random
object StressGCMonitor {
var list = List.empty[Int]
def main(args: Array[String]): Unit = {
new GCMonitor(ConsoleLogger())
val deadline = Deadline.now + 10.seconds
while (!deadline.isOverdue()) {
println(deadline.timeLeft.toSeconds + " seconds left...")
list = List.fill(1000 * 1000 * 100)(Random.nextInt(100))
System.gc()
Thread.sleep(10)
}
}
def print(): Unit = println(s"random number: ${list.sum}")
}