diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2004-10-21 15:58:07 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2004-10-21 15:58:07 +0000 |
commit | c824d58e1017c1256f278a1bc6424930c7f00e2a (patch) | |
tree | 96aa3a9dfd5e1a048045917303e2d5454431ac2c | |
parent | 4e7330335e6241a5c5260c1b1d1edadc20f93d52 (diff) | |
download | scala-c824d58e1017c1256f278a1bc6424930c7f00e2a.tar.gz scala-c824d58e1017c1256f278a1bc6424930c7f00e2a.tar.bz2 scala-c824d58e1017c1256f278a1bc6424930c7f00e2a.zip |
*** empty log message ***
-rw-r--r-- | test/benchmark/ant.private | 9 | ||||
-rw-r--r-- | test/benchmark/predef.xml | 15 | ||||
-rw-r--r-- | test/benchmark/sources/parsers/parsers.scala | 2 | ||||
-rw-r--r-- | test/benchmark/sources/tak/build.xml | 36 | ||||
-rw-r--r-- | test/benchmark/sources/tak/tak.scala | 29 | ||||
-rwxr-xr-x | test/benchmark/sources/viewtest/viewtest.scala | 2 |
6 files changed, 83 insertions, 10 deletions
diff --git a/test/benchmark/ant.private b/test/benchmark/ant.private new file mode 100644 index 0000000000..a777a19594 --- /dev/null +++ b/test/benchmark/ant.private @@ -0,0 +1,9 @@ +# the compiler executable +scala.compiler=scalac + +# the vm to run scala programs with +scala.vm=scala + +# the location where your scala distribution is +# it should point to the parent of the 'test/' directory +scala.home=${user.home}/scala diff --git a/test/benchmark/predef.xml b/test/benchmark/predef.xml index f3ae43a7f0..3cb362b14d 100644 --- a/test/benchmark/predef.xml +++ b/test/benchmark/predef.xml @@ -1,9 +1,8 @@ <project name="predef"> - <!-- Redefine accordingly to where you checked out your scala files --> - <!-- scala.home should point to the directory that contains the --> - <!-- "benchmark" directory --> - <property name="scala.home" value="${user.home}/scala"/> + <!-- Include the file defining private properties --> + <dirname property="predef.basedir" file="${ant.file.predef}"/> + <property file="${predef.basedir}/ant.private"/> <!-- Define some basic paths --> <property name="benchmark.home" value="${scala.home}/test/benchmark"/> @@ -17,7 +16,7 @@ <!-- Define a <run-benchmark> element that can be used to run --> <!-- benchmarks --> <!-- It accepts these attributes: --> - <!-- count - how many times to run each benchmark (default:3) --> + <!-- count - how many times to run each benchmark (default:5) --> <!-- classname - the name of the class to be ran (default: --> <!-- the name of the ant project --> <!-- logfile - the location of the file where running times --> @@ -26,14 +25,14 @@ <!-- up as head of the current classpath (default: --> <!-- benchmark classes dir/project name --> <macrodef name="run-benchmark"> - <attribute name="count" default="3"/> + <attribute name="count" default="5"/> <attribute name="classname" default="benchmarks.${ant.project.name}"/> <attribute name="logfile" default="${log.file}"/> <attribute name="location" default="${benchmark.classes.dir}/${ant.project.name}"/> <sequential> <echo>** Running benchmark @{classname} in @{location}..</echo> - <exec executable="scala" failonerror="true"> + <exec executable="${scala.vm}" failonerror="true"> <arg line="-cp @{location}:${java.class.path}"/> <arg line="@{classname} @{count} @{logfile}"/> </exec> @@ -54,7 +53,7 @@ <!-- name) --> <!-- files - the source files to be compiled --> <macrodef name="compile-benchmark"> - <attribute name="compiler" default="myscalac"/> + <attribute name="compiler" default="${scala.compiler}"/> <attribute name="additionalArgs" default=""/> <attribute name="destination" default="${benchmark.classes.dir}/${ant.project.name}"/> <attribute name="files"/> diff --git a/test/benchmark/sources/parsers/parsers.scala b/test/benchmark/sources/parsers/parsers.scala index 0089982eab..0191afb716 100644 --- a/test/benchmark/sources/parsers/parsers.scala +++ b/test/benchmark/sources/parsers/parsers.scala @@ -116,7 +116,7 @@ object TestExpr { } else System.out.println("usage: java examples.TestExpr <expr-string>"); } -object parsers1 with scala.testing.Benchmark { +object parsers with scala.testing.Benchmark { def run: Unit = { TestList.main(Array("(a,b,(1,2))")); TestExpr.main(Array("2+3+(4+1)")) 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); +} diff --git a/test/benchmark/sources/viewtest/viewtest.scala b/test/benchmark/sources/viewtest/viewtest.scala index 82807808bd..5c7d03f5b4 100755 --- a/test/benchmark/sources/viewtest/viewtest.scala +++ b/test/benchmark/sources/viewtest/viewtest.scala @@ -39,7 +39,7 @@ trait Tree[+a <% Ordered[a]] { } } -object viewtest1 with scala.testing.Benchmark { +object viewtest with scala.testing.Benchmark { import O.view; def run: Unit = { |