]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorPhil Dawes <phil@phildawes.net>
Tue, 5 Aug 2008 07:30:19 +0000 (08:30 +0100)
committerPhil Dawes <phil@phildawes.net>
Tue, 5 Aug 2008 07:30:19 +0000 (08:30 +0100)
extra/wordtimer/wordtimer-docs.factor
extra/wordtimer/wordtimer.factor

index 47b85bb007cc327e70e49d34df7af80a9aab63b9..c13399e0f83ba961d2b736ca34f45f601e88bfd7 100644 (file)
@@ -34,8 +34,13 @@ HELP: profile-vocab
 { $description "Annotates the words in the vocab with timing code then runs the quotation. Finally resets the words and prints the timings information."
 } ;
 
+HELP: wordtimer-call
+{ $values { "quot" "a quotation to run" } }
+{ $description "Resets the wordtimer hash and runs the quotation. After the quotation has run it prints out the timed words"
+} ;
+
     
 ARTICLE: "wordtimer" "Word Timer"
-"The " { $vocab-link "wordtimer" } " vocabulary measures accumulated execution time for words. If you just want to profile the accumulated time taken by all words in a vocab you can use " { $vocab-link "profile-vocab" } ". If you need more fine grained control then do the following: First annotate individual words with the " { $link add-timer } " word or whole vocabularies with " { $link add-timers } ". Then reset the clock with " { $link reset-word-timer } " and execute your code. Finally you can view the timings with " { $link print-word-timings } ". If you have functions that are quick and called often you may want to " { $link correct-for-timing-overhead } ". To remove all the annotations in the vocab you can use " { $link reset-vocab } ". Alternatively if you just want to time the contents of a vocabulary you can use profile-vocab." ;
+"The " { $vocab-link "wordtimer" } " vocabulary measures accumulated execution time for words. If you just want to profile the accumulated time taken by all words in a vocab you can use " { $vocab-link "profile-vocab" } ". If you need more fine grained control then do the following: First annotate individual words with the " { $link add-timer } " word or whole vocabularies with " { $link add-timers } ". Then use " { $link wordtimer-call } " to invoke a quotation and print out the timings." ;
     
 ABOUT: "wordtimer"
index 5da17e28d5d54073ff2f7e36885892e71cc0f798..15f50faa158d4983ee85b9e0febe6abb7f669a0b 100644 (file)
@@ -67,6 +67,12 @@ SYMBOL: *calling*
 : print-word-timings ( -- )
   *wordtimes* get-global [ swap suffix ] { } assoc>map natural-sort reverse pprint ;
 
+: wordtimer-call ( quot -- )
+  reset-word-timer 
+  [ call ] micro-time >r
+  correct-for-timing-overhead
+  "total time:" write r> pprint nl
+  print-word-timings nl ;
 
 : profile-vocab ( vocabspec quot -- )
   "annotating vocab..." print flush