(* To time a function (f: unit -> 'a), execute timeit f. The output is time spent in user mode, time spent in system mode, and time spent garbage collecting. Add the three to get an honest total time. All times are in seconds. *) fun timeit (f:unit ->'a) = let open System.Timer val start = start_timer() val result = f() in print "u "; print (makestring(check_timer start)); print "\t"; print "s "; print (makestring(check_timer_sys start)); print "\t"; print "gc "; print (makestring(check_timer_gc start)); print "\n"; result end