diff options
Diffstat (limited to 'examples/src/main/scala/CpuHog.scala')
-rw-r--r-- | examples/src/main/scala/CpuHog.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/src/main/scala/CpuHog.scala b/examples/src/main/scala/CpuHog.scala new file mode 100644 index 0000000000..f37c6f7824 --- /dev/null +++ b/examples/src/main/scala/CpuHog.scala @@ -0,0 +1,24 @@ +import spark._ + +object CpuHog { + def main(args: Array[String]) { + if (args.length != 3) { + System.err.println("Usage: CpuHog <master> <tasks> <threads_per_task>"); + System.exit(1) + } + val sc = new SparkContext(args(0), "CPU hog") + val tasks = args(1).toInt + val threads = args(2).toInt + def task { + for (i <- 0 until threads-1) { + new Thread() { + override def run { + while(true) {} + } + }.start() + } + while(true) {} + } + sc.runTasks(Array.make(tasks, () => task)) + } +} |