summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-12-09 22:48:33 +0000
committerBurak Emir <emir@epfl.ch>2006-12-09 22:48:33 +0000
commitaf8af21c9427532bda8f88abcf0a5f20939bb549 (patch)
tree6440a2f1808bd60bc0c824b784e3b690ced62c73 /src
parent1e5fd9b56a92dc162ce28346b0a705e8940f58d9 (diff)
downloadscala-af8af21c9427532bda8f88abcf0a5f20939bb549.tar.gz
scala-af8af21c9427532bda8f88abcf0a5f20939bb549.tar.bz2
scala-af8af21c9427532bda8f88abcf0a5f20939bb549.zip
run benchmarks with a multiplier
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/testing/Benchmark.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala
index 7f4db62de8..b2b427d4d3 100644
--- a/src/library/scala/testing/Benchmark.scala
+++ b/src/library/scala/testing/Benchmark.scala
@@ -40,6 +40,8 @@ trait Benchmark {
/** this method should be implemented by the concrete benchmark */
def run: Unit
+ var multiplier = 1
+
/** Run the benchmark the specified number of times
* and return a list with the execution times in milliseconds
* in reverse order of the execution
@@ -50,7 +52,10 @@ trait Benchmark {
def runBenchmark(noTimes: Int): List[Long] =
for (val i <- List.range(1, noTimes + 1)) yield {
val startTime = Platform.currentTime
- run
+ var i = 0; while(i < multiplier) {
+ run
+ i = i + 1
+ }
val stopTime = Platform.currentTime
Platform.collectGarbage
@@ -65,15 +70,18 @@ trait Benchmark {
def main(args: Array[String]): Unit = {
if (args.length > 1) {
val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite
-
+ if(args.length >= 2)
+ multiplier = args(2).toInt
logFile.write(getClass().getName())
for (val t <- runBenchmark(args(0).toInt))
logFile.write("\t\t" + t)
logFile.write(Platform.EOL)
logFile.flush()
- } else
+ } else {
Console.println("Usage: scala benchmarks.program <runs> <logfile>")
+ Console.println(" or: scala benchmarks.program <runs> <logfile> <multiplier>")
+ }
}
}