xref: /aosp_15_r20/external/executorch/util/cprofiler_flamegraph.md (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1## Requirements
2
3CProfilerFlameGraph depends on snakeviz to render flamegraph as html file. Main snakeviz repo requires renders flamegraph by launching webserver and rendering html through that. On some enviornments you want to just get a statically renderable html that can be shared. Snakeviz's author provides utility for this at https://gist.github.com/jiffyclub/6b5e0f0f05ab487ff607. This util just combined the patch from gist and added a util that does not need to launch server.
4
5## Installation
6
7pip install snakeviz
8
9## Usage
10
11```python
12    from util.python_profiler import CProfilerFlameGraph
13    with CProfilerFlameGraph("my_profiler.html"):
14        prog = export_to_exec_prog(model, example_inputs)
15```
16
17You should see my_profiler.html generted in the working directory.
18