From f609e1d7cdf49bec32eebda0662d1f1d3d19c401 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 21 Oct 2004 13:53:10 +0000 Subject: *** empty log message *** --- test/benchmark/build.xml | 3 +- test/benchmark/predef.xml | 6 +--- test/benchmark/sources/impfor/build.xml | 36 +++++++++++++++++++++++ test/benchmark/sources/impfor/impfor.scala | 46 ++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 test/benchmark/sources/impfor/build.xml create mode 100644 test/benchmark/sources/impfor/impfor.scala (limited to 'test') 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 @@ + - 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 @@ - - - @@ -75,4 +71,4 @@ - \ No newline at end of file + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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; +} -- cgit v1.2.3