Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howtos:profiling:gperftools [2015/06/19 08:09] – created techee | howtos:profiling:gperftools [2020/03/16 13:58] (current) – OS X to macOS 邢家朋 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Profiling with gperftools ====== | ====== Profiling with gperftools ====== | ||
+ | [[https:// | ||
+ | ==== Installation ==== | ||
+ | On debian-based systems the tools are packaged under the google-perftools package. For graphical output you also need graphviz installed: | ||
+ | |||
+ | < | ||
+ | sudo apt-get install google-perftools graphviz | ||
+ | </ | ||
+ | |||
+ | Note that all the tools have the " | ||
+ | |||
+ | ==== Profiling the whole process runtime ==== | ||
+ | This section describes profiling a process from its start to its termination. This can be useful to profile the start and termination times of Geany. | ||
+ | |||
+ | - To start profiling, run < | ||
+ | LD_PRELOAD=/ | ||
+ | </ | ||
+ | - Do whatever you want to profile in Geany. When finished, close Geany. | ||
+ | - At this point, / | ||
+ | google-pprof --web / | ||
+ | </ | ||
+ | |||
+ | Every node represents a function called. Gpreftools uses sample-based profiling so at regular intervals it checks which function is being called and records this number for each function. These numbers are then shown in the graph - the first number in every function corresponds to the time spent in the function itself, the second number is the total time spent in the function plus all the functions the function calls. More useful than the sample numbers is the percentual information telling us how many percents of the total time are spent in the given function. | ||
+ | |||
+ | In the above graph we can see the skipEverything() function takes 55.2% of total time so it looks like a good candidate for optimization. | ||
+ | |||
+ | **Note**: I keep getting the < | ||
+ | |||
+ | **Note**: I wasn't able to get profiles with reasonable level of information from the GTK libraries provided by the system so if there is some GTK-related problem, it's best to compile GTK by yourself. | ||
+ | |||
+ | ==== Profiling only part of the process runtime ==== | ||
+ | Most often in Geany it's much more useful to profile just some particular feature such as what CPU amount is used when just typing text (which involves all the ctags parsing, tag management, symbol tree updates and scintilla lexing and displaying). In these cases we don't want the profile to contain irrelevant information e.g. from what Geany does when it's started or terminated. | ||
+ | |||
+ | Fortunately, | ||
+ | |||
+ | - Run < | ||
+ | LD_PRELOAD=/ | ||
+ | </ | ||
+ | - Perform any preparation steps in Geany that shouldn' | ||
+ | - Tell the profiler to start profiling: < | ||
+ | killall -12 geany | ||
+ | </ | ||
+ | - Now perform the action you want to profile in Geany, e.g. start typing. | ||
+ | - Tell the profiler to stop profiling by sending it the signal again: < | ||
+ | killall -12 geany | ||
+ | </ | ||
+ | - Display the profile in the browser: < | ||
+ | google-pprof --web / | ||
+ | </ | ||
+ | |||
+ | ==== macOS ==== | ||
+ | There' | ||
+ | |||
+ | ==== Other options ==== | ||
+ | There are many additional options in gperftools and while I found the above sufficient for profiling Geany, there may be cases where some extra parameter may be necessary (such as filtering the graph to some subset, more frequent sampling, etc.). See the CPU profiler [[http:// |