GreyLensman gave me a function to time function calls, but I was wondering if there were a standard way to do this.

Here's his code:

fun time thunk =  
    let val t0 = Time.now() 
    in 
        thunk(); 
        print ("Done: " ^ (Time.toString (Time.- (Time.now(),t0)))); 
        print "\n" 
    end 

And here is a sample usage:

fun fact(0) = 1 
 | fact(n) = n * fact(n-1); 
 
fun wrapper() = fact(12); (* 13 causes overflow *) 
 
time wrapper; 

-- Terrence Brannon

StandardWayToTimeFunctions (last edited 2008-07-09 05:47:51 by localhost)