CookBook/Recipes/Timing.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 01 Mar 2009 21:48:59 +0000
changeset 154 e81ebb37aa83
child 155 b6fca043a796
permissions -rw-r--r--
updated to repository version; added a section about timing

theory Timing
imports "../Base"
begin

section {* Measuring the Time of an Operation\label{rec:timing} *} 

text {*
 {\bf Problem:}
  You want to measure the running time of a tactic or function.\smallskip

  {\bf Solution:} Time can be measured using the function 
  @{ML start_timing} and @{ML end_timing}.\smallskip

*}

ML{*fun ackermann (0, n) = n + 1
  | ackermann (m, 0) = ackermann (m - 1, 1)
  | ackermann (m, n) = ackermann (m - 1, ackermann (m, n - 1)) *}

ML {*
let
  val start = start_timing ()
  val res = ackermann (3,12)
  val time = (end_timing start)
in
 (res,time)
end
*}

text {*
  check what @{text "#all"} does?
*}

end