summaryrefslogtreecommitdiff
path: root/test/benchmark
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2004-10-21 13:53:10 +0000
committerIulian Dragos <jaguarul@gmail.com>2004-10-21 13:53:10 +0000
commitf609e1d7cdf49bec32eebda0662d1f1d3d19c401 (patch)
treea2bb0ea066436e282894fab19f0b8d6b81a580fd /test/benchmark
parentbb73b041480e06dac7fc1e851776a3654541e594 (diff)
downloadscala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.tar.gz
scala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.tar.bz2
scala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.zip
*** empty log message ***
Diffstat (limited to 'test/benchmark')
-rw-r--r--test/benchmark/build.xml3
-rw-r--r--test/benchmark/predef.xml6
-rw-r--r--test/benchmark/sources/impfor/build.xml36
-rw-r--r--test/benchmark/sources/impfor/impfor.scala46
4 files changed, 85 insertions, 6 deletions
diff --git a/test/benchmark/build.xml b/test/benchmark/build.xml
index da7645d81e..346285163a 100644
--- a/test/benchmark/build.xml
+++ b/test/benchmark/build.xml
@@ -4,6 +4,7 @@
<target name="init" depends="clean.benchmark">
<mkdir dir="${benchmark.classes.dir}"/>
+ <mkdir dir="times"/>
</target>
<target name="clean.benchmark"
@@ -11,7 +12,7 @@
<delete dir="${benchmark.classes.dir}"/>
</target>
- <target name="run.benchmark"
+ <target name="run.benchmark" depends="init"
description="Run the benchmark suite">
<subant inheritAll="false">
diff --git a/test/benchmark/predef.xml b/test/benchmark/predef.xml
index 72bab526fe..f3ae43a7f0 100644
--- a/test/benchmark/predef.xml
+++ b/test/benchmark/predef.xml
@@ -14,10 +14,6 @@
<property name="log.file"
value="${benchmark.home}/times/times.log"/>
- <!-- Define the scalac task -->
- <taskdef name="scalac"
- classname="scala.tools.scala4ant.ScalacTask$class"/>
-
<!-- Define a <run-benchmark> element that can be used to run -->
<!-- benchmarks -->
<!-- It accepts these attributes: -->
@@ -75,4 +71,4 @@
</sequential>
</macrodef>
-</project> \ No newline at end of file
+</project>
diff --git a/test/benchmark/sources/impfor/build.xml b/test/benchmark/sources/impfor/build.xml
new file mode 100644
index 0000000000..4feb4599f8
--- /dev/null
+++ b/test/benchmark/sources/impfor/build.xml
@@ -0,0 +1,36 @@
+<project name="impfor" default="run">
+
+ <import file="../../predef.xml"/>
+
+ <target name="init">
+ <mkdir dir="${benchmark.classes.dir}/${ant.project.name}"/>
+ </target>
+
+ <!-- Compile the impfor benchmark without optimizations -->
+ <target name="compile-noopt"
+ description="Compile the ${ant.project.name} benchmark with no optimizations">
+ <compile-benchmark files="${benchmark.sources.dir}/${ant.project.name}/impfor.scala"
+ destination="${benchmark.classes.dir}/${ant.project.name}/noopt"/>
+ </target>
+
+ <!-- Compile the impfor benchmark with optimizations -->
+ <target name="compile-opt"
+ description="Compile the ${ant.project.name} benchmark with opt">
+ <compile-benchmark files="${benchmark.sources.dir}/${ant.project.name}/impfor.scala"
+ destination="${benchmark.classes.dir}/${ant.project.name}/opt"
+ additionalArgs="-separate:no -Xinline"/>
+ </target>
+
+
+ <target name="run" depends="init,compile-noopt,compile-opt"
+ description="Run this benchmark">
+ <run-benchmark location="${benchmark.classes.dir}/${ant.project.name}/noopt"/>
+ <run-benchmark location="${benchmark.classes.dir}/${ant.project.name}/opt"/>
+ </target>
+
+ <target name="clean.benchmark"
+ description="Clean the object files for ${ant.project.name} benchmark">
+ <delete dir="${benchmark.classes.dir}/${ant.project.name}"/>
+ </target>
+
+</project>
diff --git a/test/benchmark/sources/impfor/impfor.scala b/test/benchmark/sources/impfor/impfor.scala
new file mode 100644
index 0000000000..f02a4ba31b
--- /dev/null
+++ b/test/benchmark/sources/impfor/impfor.scala
@@ -0,0 +1,46 @@
+/* __ *\
+** ________ ___ / / ___ Scala benchmark suite **
+** / __/ __// _ | / / / _ | (c) 2003-2004, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+** $Id$
+\* */
+
+
+package benchmarks;
+
+/** Imperative for construct. Translated from MLton benchmarking suite */
+
+class For {
+ def impFor[A](start: Int, stop: Int, f: Int => A) = {
+ var i = start;
+ def loop: Unit = if (i >= stop) ()
+ else { f(i); i = i + 1; loop }
+
+ loop;
+ }
+}
+
+
+object impfor extends For with scala.testing.Benchmark {
+
+ def doit: Unit = {
+ var x = 0;
+
+ impFor(0, 10, t =>
+ impFor(0, 10, t =>
+ impFor(0, 10, t =>
+ impFor(0, 10, t =>
+ impFor(0, 10, t =>
+ impFor(0, 10, t =>
+ impFor(0, 10, t => x = x + 1))))))); // 7 inner loops
+
+ if (x != 10000000) {
+ Console.println("Error");
+ System.exit(1);
+ }
+ }
+
+ def run: Unit = doit;
+}