Skip to main content

Statistical profiler which outputs in format suitable for FlameGraph

Project description

A simple statistical profiler which outputs in format suitable for FlameGraph.

INSTALL:

Simply run:

pip install git+https://github.com/evanhempel/python-flamegraph.git

USAGE:

Run your script under the profiler:

python -m flamegraph -o perf.log myscript.py --your-script args here

Run Brendan Gregg’s FlameGraph tool against the output:

flamegraph.pl --title "MyScript CPU" perf.log > perf.svg

Enjoy the output:

Attic create flame graph

Filtering

Sometimes you may want to exclude a method (for example in a server the method that waits for a new request) or you may want to profile only a subset of your code (a particular method and its children which are performance critical).

Filtering can be done by passing a python regular expression to the -f or --filter command line option which will restrict output to only those lines which match. Filtering is done against the entire line so you can filter by function name, thread name, both, or even by more complex filters such as function ABC calls DEF (ABC.*DEF).

Alternatively since the output is stackframes each on a line by itself, this can simply be done with a simple grep filter.:

Exclude:

  grep -v waiting_method perf.log > removed_waiting.log

Include:

  grep function_name perf.log > filtered.log

Then run the flamegraph.pl script against the filtered file.

yCanta webapp full profile of PDF export

Full profile output of yCanta webapp PDF export. Most time is spent in wait state and graph is not very helpful.

yCanta webapp filtered for PDF export format function.

Filtered profile output of yCanta webapp PDF export. Filtering was on the pdf format function so time spent in wait state has been excluded and the graph is now helpful.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flamegraph-0.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file flamegraph-0.1.tar.gz.

File metadata

  • Download URL: flamegraph-0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flamegraph-0.1.tar.gz
Algorithm Hash digest
SHA256 2c45efc8eef0de0e2d088a82c033f6a6aa79d8f9a551de83e555be2a9dbb2452
MD5 561a009d2435611215b497efbf84c596
BLAKE2b-256 4ac0349ab6f90f2f9b325da25b33e7a7a050fa8c65eb4f7554190bd4d830efa3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page