4.6 Timing: the Timer structure

printTiming

Function

Structure

Shell.Timer

Type

val printTiming: {function: 'a -> 'b, name: string, 
      stream: MLWorks.IO.outstream} -> 'a -> 'b

Syntax

printTiming {function=f, name=n, stream=MLWorks.IO.outstream} a -> g

Arguments

f
A function.

n
A string.

a
An argument for f.

Values

g
The return value for f applied to a.

Description

This function returns the value of f applied to a, and as a side effect it prints the time taken to evaluate the expression. This function is deprecated.

Example

Define the following function:

fun g x = let 
  fun f 0 _ = ()
   | f n m = (f m 0; f (n-1) m)
     in  f x x
  end;

Below is an example of applying printTiming to g with an argument of 1000:

MLWorks>printTiming {function =g, 
                     name="hello",
                     stream=MLWorks.IO.std_out} 1000;
Time for hello : 0.54 (user: 0.49, system: 0.00, gc: 0.00)
val it : unit = ()
MLWorks>


MLWorks Reference Manual (version 1.0) - 3 DEC 1996

Generated with Harlequin WebMaker