diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2004-10-21 13:53:10 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2004-10-21 13:53:10 +0000 |
commit | f609e1d7cdf49bec32eebda0662d1f1d3d19c401 (patch) | |
tree | a2bb0ea066436e282894fab19f0b8d6b81a580fd /test/benchmark/sources | |
parent | bb73b041480e06dac7fc1e851776a3654541e594 (diff) | |
download | scala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.tar.gz scala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.tar.bz2 scala-f609e1d7cdf49bec32eebda0662d1f1d3d19c401.zip |
*** empty log message ***
Diffstat (limited to 'test/benchmark/sources')
-rw-r--r-- | test/benchmark/sources/impfor/build.xml | 36 | ||||
-rw-r--r-- | test/benchmark/sources/impfor/impfor.scala | 46 |
2 files changed, 82 insertions, 0 deletions
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; +} |