]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/profiler/profiler-docs.factor
Remove stack effects from HELP: declarations.
[factor.git] / basis / tools / profiler / profiler-docs.factor
1 USING: tools.profiler.private tools.time tools.crossref
2 help.markup help.syntax quotations io strings words definitions ;
3 IN: tools.profiler
4
5 ARTICLE: "profiler-limitations" "Profiler limitations"
6 "Certain optimizations performed by the compiler can inhibit accurate call counting:"
7 { $list
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."
12 } ;
13
14 ARTICLE: "profiling" "Profiling code" 
15 "The " { $vocab-link "tools.profiler" } " vocabulary implements a simple call counting profiler."
16 $nl
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:"
20 { $subsections
21     profile.
22     vocab-profile.
23     usage-profile.
24     vocabs-profile.
25     method-profile.
26     "profiler-limitations"
27 }
28 { $see-also "ui.tools.profiler" "tools.annotations" "timing" } ;
29
30 ABOUT: "profiling"
31
32 HELP: counters
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." } ;
35
36 HELP: counters.
37 { $values { "assoc" "an association list mapping words to integers" } }
38 { $description "Prints an association list of call counts to " { $link output-stream } "." } ;
39
40 HELP: profile
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." } ;
43
44 HELP: profile.
45 { $description "Prints a table of call counts from the most recent invocation of " { $link profile } "." } ;
46
47 HELP: vocab-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." } } ;
51
52 HELP: usage-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." } } ;
57
58 HELP: vocabs-profile.
59 { $description "Print a table of cumilative call counts for each vocabulary. Vocabularies whose words were not called are supressed from the output." } ;
60
61 HELP: method-profile.
62 { $description "Print a table of cumilative call counts for each method. Methods which were not called are supressed from the output." } ;
63
64 HELP: profiling
65 { $values { "?" "a boolean" } }
66 { $description "Internal primitive to switch on call counting. This word should not be used; instead use " { $link profile } "." } ;
67
68 { time profile } related-words