Output the call graph with PyCallGraph

This is a call graph output method that can be used when finding a processing speed bottleneck or when checking the interrelationship of objects. (Windows environment)

procedure

  1. Install pycallgraph. (Introduction of Graphviz is a prerequisite) $ pip install pycallgraph

  2. Copy C: \ Python34 \ Scripts \ pycallgraph to the root of your project. (If you play with sys.path, you may not need to copy it. Environment variables seem to be useless.)

  3. Launch the shell at the root of the project where you want to see the call graph. Run pycallgraph. $ python pycallgraph graphviz-./filename.py

  4. Since the program is executed, perform the process you want to draw the call graph.

  5. When you exit the program, pycallgraph.png will be created in the current directory.

There may be a more correct way.

(Output result when creating an empty window with PySide) PySideで空のウィンドウを作ったときの出力結果

Postscript

It might be easier to write a process to add a filter to the config of C: \ Python34 \ Lib \ site-packages \ pycallgraph \ pycallgraph.py.

~~ When outputting in a format such as DOT or SVG, or changing the output file name, C:\Python34\Lib\site-packages\pycallgraph\output\graphviz.py It is possible for the time being by changing the initial value in init. ~~ ** [2015.05.03 postscript] I was able to specify it with --output-format **

As mentioned in the source, the format can specify the following types. Output Formats | Graphviz - Graph Visualization Software

Reference site

PythonCallGraph Graphviz

Recommended Posts

Output the call graph with PyCallGraph
Call the API with python3.
Output networkX graph with graphviz (PyGraphviz)
[Python] Set the graph range with matplotlib
Increase the font size of the graph with matplotlib
The basis of graph theory with matplotlib animation
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
Output PDF with Django
Markdown output with Django
[Python] Get the numbers in the graph image with OCR
Output PDF with WeasyPrint
Band graph with matplotlib
[Neo4J] ④ Try to handle the graph structure with Cypher
Call bash with golang
The story that Japanese output was confused with Django
Display / update the graph according to the input with PySimpleGui
Display the graph while changing the parameters with PySimpleGUI + Matplotlib
Call the C function with dart: ffi and call the Dart function callback
Save the output of GAN one by one ~ With the implementation of GAN by PyTorch ~
[pyqtgraph] Add region to the graph and link it with the graph region
Draw a graph with NetworkX
Insert the debugger with nose
Kill the process with sudo kill -9
Try Python output with Haxe 3.2
Test standard output with Pytest
Create graph with plotly button
Output to syslog with Loguru
Graph drawing method with matplotlib
Output large log with discord.py
Graph Excel data with matplotlib (2)
Guess the password with klee
gethostbyaddr () communicates with the outside
Cut the PyTorch calculation graph
scraping the Nikkei 225 with playwright-python
Check the code with flake8
Calibrate the model with PyCaret
Connected components of the graph
Filter the output of tracemalloc
Draw a graph with networkx
Graph drawing with IPython Notebook
Read the coordinates of the plot on the graph with Python-matplotlib (super beginner)
The first artificial intelligence. Challenge web output with python. ~ Flask introduction
[Statistics] Grasp the image of the central limit theorem with a graph
I want to output the beginning of the next month with Python
Output the contents of ~ .xlsx in the folder to HTML with Python
Count the maximum concatenated part of a random graph with NetworkX