1 USING: tools.profiler.private tools.time tools.crossref
2 help.markup help.syntax quotations io strings words definitions ;
5 ARTICLE: "profiler-limitations" "Profiler limitations"
6 "Certain optimizations performed by the compiler can inhibit accurate call counting:"
8 "Calls to open-coded intrinsics are not counted. Certain words are open-coded as inline machine code, and in some cases optimized out altogether; this includes stack shuffling operations, conditionals, and many object allocation operations."
9 { "Calls to " { $link POSTPONE: inline } " words are not counted." }
10 { "Calls to methods which were inlined as a result of type inference are not counted." }
11 "Tail-recursive loops will only count the initial invocation of the word, not every tail call."
14 ARTICLE: "profiling" "Profiling code"
15 "The " { $vocab-link "tools.profiler" } " vocabulary implements a simple call counting profiler."
17 "Quotations can be passed to a combinator which calls them with the profiler enabled:"
18 { $subsections profile }
19 "After a quotation has been profiled, call counts can be presented in various ways:"
26 "profiler-limitations"
28 { $see-also "ui.tools.profiler" "tools.annotations" "timing" } ;
33 { $values { "words" "a sequence of words" } { "alist" "an association list mapping words to integers" } }
34 { $description "Outputs an association list of word call counts." } ;
37 { $values { "assoc" "an association list mapping words to integers" } }
38 { $description "Prints an association list of call counts to " { $link output-stream } "." } ;
41 { $values { "quot" quotation } }
42 { $description "Calls the quotation while collecting word call counts, which can then be displayed using " { $link profile. } " or related words." } ;
45 { $description "Prints a table of call counts from the most recent invocation of " { $link profile } "." } ;
48 { $values { "vocab" string } }
49 { $description "Prints a table of call counts from the most recent invocation of " { $link profile } ", for words in the " { $snippet "vocab" } " vocabulary only." }
50 { $examples { $code "\"math\" vocab-profile." } } ;
53 { $values { "word" word } }
54 { $description "Prints a table of call counts from the most recent invocation of " { $link profile } ", for words which directly call " { $snippet "word" } " only." }
55 { $notes "This word obtains the list of static usages with the " { $link smart-usage } " word, and is not aware of dynamic call history. Consider the following scenario. A word " { $snippet "X" } " can execute word " { $snippet "Y" } " in a conditional branch, and " { $snippet "X" } " is executed many times during the profiling run, but this particular branch executing " { $snippet "Y" } " is never taken. However, some other word does execute " { $snippet "Y" } " multiple times. Then " { $snippet "\\ Y usage-profile." } " will list a number of calls to " { $snippet "X" } ", even though " { $snippet "Y" } " was never executed " { $emphasis "from" } " " { $snippet "X" } "." }
56 { $examples { $code "\\ + usage-profile." } } ;
59 { $description "Print a table of cumilative call counts for each vocabulary. Vocabularies whose words were not called are supressed from the output." } ;
62 { $description "Print a table of cumilative call counts for each method. Methods which were not called are supressed from the output." } ;
65 { $values { "?" "a boolean" } }
66 { $description "Internal primitive to switch on call counting. This word should not be used; instead use " { $link profile } "." } ;
68 { time profile } related-words