CookBook/Recipes/Timing.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 05 Mar 2009 16:46:43 +0000
changeset 160 cc9359bfacf4
parent 157 76cdc8f562fc
child 167 3e30ea95c7aa
permissions -rw-r--r--
redefined the functions warning and tracing in order to properly match more antiquotations

theory Timing
imports "../Base"
begin

section {* Measuring Time\label{rec:timing} (TBD) *} 

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 {* timeap *}

fun 
 ackermann:: "(nat * nat) \<Rightarrow> nat"
where
    "ackermann (0, n) = n + 1"
  | "ackermann (m, 0) = ackermann (m - 1, 1)"
  | "ackermann (m, n) = ackermann (m - 1, ackermann (m, n - 1))"

text {* Does not work yet! *}

lemma "ackermann (3, 4) = 125"
apply(tactic {* timeap  (asm_full_simp_tac (@{simpset} addsimps @{thms "nat_number"})) 1 *})
(*
apply(tactic {* 
  let 
    val start = start_timing ();
    val res = asm_full_simp_tac (@{simpset} addsimps @{thms "nat_number"}) 1;
  in
    (warning (#message  (end_timing start)); res)
  end *})*)
done

end