1 ! (c)2010 Joe Groff bsd license
2 USING: arrays calendar help.markup help.syntax math quotations threads
3 tools.profiler.sampling.private ;
4 IN: tools.profiler.sampling
6 { cross-section flat top-down top-down-max-depth profile profile. } related-words
7 { cross-section* flat* top-down* top-down-max-depth* most-recent-profile-data } related-words
9 { total-sample-count gc-sample-count jit-sample-count foreign-sample-count foreign-thread-sample-count sample-thread sample-callstack } related-words
11 { total-time gc-time foreign-time foreign-thread-time } related-words
16 { "tree" "a profile report" }
18 { $description "Generates a cross-section profile at " { $snippet "depth" } " from the results of the most recent " { $link profile } ". Each sample's time will be charged to the function " { $snippet "depth" } " levels deep in the callstack, or to the deepest function in the callstack if the callstack at the time of the sample is fewer than " { $snippet "depth" } " levels deep. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
22 { "depth" integer } { "profile-data" "raw profile data" }
23 { "tree" "a profile report" }
25 { $description "Generates a cross-section profile at " { $snippet "depth" } " from the profile results in " { $snippet "profile-data" } ". Each sample's time will be charged to the function " { $snippet "depth" } " levels deep in the callstack, or to the deepest function in the callstack if the callstack at the time of the sample is fewer than " { $snippet "depth" } " levels deep. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
29 { "flat" "a profile report" }
31 { $description "Generates a flat profile from the results of the most recent " { $link profile } ". Each sample's time will be charged to every function in the callstack at the time of the sample. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
35 { "profile-data" "raw profile data" }
36 { "flat" "a profile report" }
38 { $description "Generates a flat profile from the profile results in " { $snippet "profile-data" } ". Each sample's time will be charged to every function in the callstack at the time of the sample. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
40 HELP: foreign-sample-count
42 { "sample" "a raw profile sample" }
45 { $description "Returns the number of sample intervals spent in non-Factor code (such as the Factor VM, or FFI calls) during " { $snippet "sample" } "." } ;
47 HELP: foreign-thread-sample-count
49 { "sample" "a raw profile sample" }
52 { $description "Returns the number of sample intervals spent executing non-Factor threads within the Factor process during " { $snippet "sample" } "." } ;
54 HELP: foreign-thread-time
58 { $description "Returns the total time spent executing non-Factor threads within the Factor process during the last " { $link profile } "." } ;
60 HELP: foreign-thread-time*
62 { "profile-data" "raw profile data" }
65 { $description "Returns the total time spent executing non-Factor threads within the Factor process from the given " { $snippet "profile-data" } "." } ;
71 { $description "Returns the total time spent in non-Factor code (such as the Factor VM, or FFI calls) during the last " { $link profile } "." } ;
75 { "profile-data" "raw profile data" }
78 { $description "Returns the total time spent in non-Factor code (such as the Factor VM, or FFI calls) from the given " { $snippet "profile-data" } "." } ;
82 { "sample" "a raw profile sample" }
85 { $description "Returns the number of sample intervals spent in the garbage collector during " { $snippet "sample" } "." } ;
91 { $description "Returns the total time spent in the garbage collector during the last " { $link profile } "." } ;
95 { "profile-data" "raw profile data" }
98 { $description "Returns the total time spent in the garbage collector from the given " { $snippet "profile-data" } "." } ;
100 HELP: jit-sample-count
102 { "sample" "a raw profile sample" }
105 { $description "Returns the number of sample intervals spent in the non-optimizing compiler during " { $snippet "sample" } "." } ;
107 HELP: most-recent-profile-data
109 { "profile-data" "raw profile data" }
111 { $description "Returns the raw profile data from the most recent " { $link profile } ". This data can be saved and used with the " { $snippet "*" } " variants of reporting words, such as " { $link top-down* } " and " { $link flat* } ", independent of later executions of the profiler.." } ;
117 { $description "Executes " { $snippet "quot" } " with the sampling profiler enabled. The results of the profile can subsequently be reported with words such as " { $link top-down } " and " { $link flat } ", or the raw data can be saved and inspected with " { $link most-recent-profile-data } "." } ;
120 { $class-description "Objects of this type are generated by profile reporting words such as " { $link top-down } ", " { $link top-down-max-depth } ", " { $link cross-section } ", and " { $link flat } "." } ;
124 { "tree" "a profile report" }
126 { $description "Formats and prints a profile report generated by " { $link top-down } ", " { $link top-down-max-depth } ", " { $link cross-section } ", or " { $link flat } "." } ;
128 HELP: raw-profile-data
129 { $var-description "Holds raw profiling data. Set by the " { $link profile } " word after the profiling run is over." } ;
131 HELP: sample-callstack
133 { "sample" "a raw profile sample" }
136 { $description "Returns the callstack (the stack of functions currently executing) at the time of " { $snippet "sample" } "." } ;
140 { "sample" "a raw profile sample" }
143 { $description "Returns the currently-executing Factor thread at the time of " { $snippet "sample" } "." } ;
145 HELP: samples-per-second
146 { $var-description "This variable controls the rate at which the profiler takes samples during calls to " { $link profile } "." } ;
150 { "samples" integer }
151 { "seconds" integer }
153 { $description "Converts a sample interval count to an integer based on the value of " { $link samples-per-second } "." } ;
157 { "tree" "a profile report" }
159 { $description "Generates a top-down tree profile from the results of the most recent " { $link profile } ". The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
163 { "profile-data" "raw profile data" }
164 { "tree" "a profile report" }
166 { $description "Generates a top-down tree profile from the profile results in " { $snippet "profile-data" } ". The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
168 HELP: top-down-max-depth
170 { "max-depth" integer }
171 { "tree" "a profile report" }
173 { $description "Generates a top-down tree profile from the results of the most recent " { $link profile } ". Functions at a callstack depth greater than " { $snippet "max-depth" } " will be filtered out. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
175 HELP: top-down-max-depth*
177 { "max-depth" integer } { "profile-data" "raw profile data" }
178 { "tree" "a profile report" }
180 { $description "Generates a top-down tree profile from the profile results in " { $snippet "profile-data" } ". Functions at a callstack depth greater than " { $snippet "max-depth" } " will be filtered out. The output " { $snippet "tree" } " can be printed with the " { $link profile. } " word." } ;
182 HELP: total-sample-count
184 { "sample" "a raw profile sample" }
187 { $description "Returns the total number of sample intervals spent during " { $snippet "sample" } "." } ;
193 { $description "Returns the total time spent during the most recent " { $link profile } "." } ;
197 { "profile-data" "raw profile data" }
200 { $description "Returns the total time spent from the given " { $snippet "profile-data" } "." } ;
202 ARTICLE: "tools.profiler.sampling" "Sampling profiler"
203 "The " { $vocab-link "tools.profiler.sampling" } " vocabulary provides an interface to Factor's sampling profiler. It provides words for running the profiler:"
204 { $subsections profile }
205 "General statistics can then be collected:"
206 { $subsections total-time gc-time foreign-time foreign-thread-time }
207 "More detailed by-function profile reports can be generated:"
208 { $subsections top-down top-down-max-depth cross-section flat }
209 "The report data can then be printed:"
210 { $subsections profile. }
211 "Profile data can be saved for future reporting:"
212 { $subsections most-recent-profile-data top-down* top-down-max-depth* cross-section* flat* }
213 "For example, the following will profile a call to the foo word, and generate and display a top-down tree profile from the results:"
214 { $code "[ foo ] profile
218 ABOUT: "tools.profiler.sampling"
225 ! not compensated for sample collection time
226 ! nearest-neighbor reporting