Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

add profiling scripts #286

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

QiJune
Copy link
Member

@QiJune QiJune commented Apr 17, 2017

#279
Python provides cProfile module to help us profiling python codes. A common usage can be:
python -m cProfile -o train.prof train.py

Since train.prof is a binary file, we have to transfer it into readable text or graph. The Pstats module’s Stats class has a variety of methods for manipulating and printing the data saved into a profile results file. Following is the usage:

import pstats
p = pstats.Stats('train.prof)
p.strip_dirs().sort_stats("time").print_stats(20)
p.strip_dirs().sort_stats("cumtime").print_stats(20)

And gprof2dot is a Python script to convert the output from profilers into a dot graph. Following is the usage:

gprof2dot -f pstats train.prof | dot -Tpng -o train.prof.png

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants