this repo has no description
1# `_profiler` Module
2
3Skybison now comes with a built-in python profiler that counts executed opcodes
4and produces call data in callgrind format that can be read with
5qcachegrind/kcachegrind (see [cpp-profiling](cpp-profiling.md) for Tips about
6qcachegrind).
7
8Note: Counting opcodes isn't necessarily the best measure for performance... we
9plan to add other metrics later.
10
11Basic Usage
12========
13
14Profiling is enable form sourcecode:
15```
16import _profiler
17
18_profiler.install()
19# Code Here will be profiled, you can dump intermediate state at any time:
20
21_profiler.dump_callgrind("phase1.cg") # dumps phase1.cg file, and resets counters
22...
23_profiler.dump_callgrind("phase2.cg")
24...
25```
26
27Note: `_profiler.install()` also currently has a limitation where it does not
28always affect outer callframes and may miss opcodes there. It is recommended to
29only call it at the module level to avoid this problem (and not inside
30functions). Calling `dump_callgrind` in fine anywhere.