| 1 |
(****************************************************************************** |
| 2 |
* File: diviter.sml |
| 3 |
* Description: DIV benchmarks |
| 4 |
* Author: Richard Gabriel |
| 5 |
* Created: 8-Apr-85 |
| 6 |
* Modified: 19-Jul-85 18:28:01 (Bob Shaw) |
| 7 |
* 23-Jul-87 (Will Clinger: translated into Scheme) |
| 8 |
* 4-May-94 (Will Clinger: translated into SML) |
| 9 |
* 24-Jun-99 (Will Clinger: split into two files) |
| 10 |
* Language: Standard ML |
| 11 |
* Status: Public Domain |
| 12 |
******************************************************************************) |
| 13 |
|
| 14 |
(* DIV2 -- Benchmark which divides by 2 using lists of n []'s. *) |
| 15 |
|
| 16 |
fun create_n n = |
| 17 |
let fun loop (n, a) = |
| 18 |
if n = 0 |
| 19 |
then a |
| 20 |
else loop (n-1, []::a) |
| 21 |
in loop (n, []) |
| 22 |
end |
| 23 |
|
| 24 |
val ll = create_n 200 |
| 25 |
|
| 26 |
fun recursive_div2 [] = [] |
| 27 |
| recursive_div2 (x::y::z) = x :: (recursive_div2 z) |
| 28 |
|
| 29 |
fun div_rec (n) = |
| 30 |
run_benchmark ("divrec", n, fn () => recursive_div2 ll, |
| 31 |
fn (x) => length x = 100) |
| 32 |
|
| 33 |
fun main () = div_rec (diviter_iters) |