diff options
Diffstat (limited to 'test/benchmark/sources/tak')
-rw-r--r-- | test/benchmark/sources/tak/build.xml | 36 | ||||
-rw-r--r-- | test/benchmark/sources/tak/tak.scala | 29 |
2 files changed, 65 insertions, 0 deletions
diff --git a/test/benchmark/sources/tak/build.xml b/test/benchmark/sources/tak/build.xml new file mode 100644 index 0000000000..1fbef5e75d --- /dev/null +++ b/test/benchmark/sources/tak/build.xml @@ -0,0 +1,36 @@ +<project name="tak" default="run"> + + <import file="../../predef.xml"/> + + <target name="init"> + <mkdir dir="${benchmark.classes.dir}/${ant.project.name}"/> + </target> + + <!-- Compile the tak 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}/tak.scala" + destination="${benchmark.classes.dir}/${ant.project.name}/noopt"/> + </target> + + <!-- Compile the tak 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}/tak.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/tak/tak.scala b/test/benchmark/sources/tak/tak.scala new file mode 100644 index 0000000000..6ee989328f --- /dev/null +++ b/test/benchmark/sources/tak/tak.scala @@ -0,0 +1,29 @@ +/* __ *\ +** ________ ___ / / ___ Scala benchmark suite ** +** / __/ __// _ | / / / _ | (c) 2003-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ + +package benchmarks; + +/** The Tak recursive function. Translated from the MLton benchmarking + suite. */ +class Tak { + def tak(x: Int, y: Int, z: Int): Int = + if (! (y < x)) + z + else + tak (tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, z, y)); + + def f(x: Int): Unit = x match { + case 0 => (); + case n => {tak (36, 42, 12); f (n - 1) } + } +} + +object tak extends Tak with scala.testing.Benchmark { + def run = f(10000); +} |