src/Pure/library.ML
changeset 4326 7211ea5f29e2
parent 4284 eb65491ae776
child 4343 9849fb57c395
equal deleted inserted replaced
4325:e72cba5af6c5 4326:7211ea5f29e2
   799   end;
   799   end;
   800 
   800 
   801 
   801 
   802 
   802 
   803 (** timing **)
   803 (** timing **)
       
   804 
       
   805 (*a conditional timing function: applies f to () and, if the flag is true,
       
   806   prints its runtime*)
       
   807 fun cond_timeit flag f =
       
   808   if flag then
       
   809     let val start = startTiming()
       
   810         val result = f ()
       
   811     in
       
   812 	writeln (endTiming start);  result
       
   813     end
       
   814   else f ();
   804 
   815 
   805 (*unconditional timing function*)
   816 (*unconditional timing function*)
   806 fun timeit x = cond_timeit true x;
   817 fun timeit x = cond_timeit true x;
   807 
   818 
   808 (*timed application function*)
   819 (*timed application function*)