Skip to content

Commit 1b6b714

Browse files
committed
pycallgraph
1 parent 81f9be4 commit 1b6b714

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Library
1010
Library/*
1111
Library.zip
1212
*.log
13+
call_detail.png
1314
Resources/Data/*
1415
Resources/Images/Avatars/*.jpg
1516
Resources/Images/Wallpaper/*

PyQtClient.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,36 @@ def showError(message):
7272
sys.exit(app.exec_())
7373

7474

75-
try:
75+
def do_analysis():
7676
from Widgets import MainWindow
77-
MainWindow.main()
77+
try:
78+
# 获取函数调用图
79+
from pycallgraph2.config import Config
80+
from pycallgraph2.globbing_filter import GlobbingFilter
81+
from pycallgraph2.output.graphviz import GraphvizOutput
82+
from pycallgraph2.pycallgraph import PyCallGraph
83+
# 函数流程图调用
84+
config = Config()
85+
config.trace_filter = GlobbingFilter(
86+
include=['Widgets.*', 'Utils.*'],
87+
exclude=['pycallgraph2.*', '*.secret_function']
88+
)
89+
with PyCallGraph(
90+
GraphvizOutput(
91+
tool='D:/soft/Graphviz/bin/dot',
92+
output_file='call_detail.png'),
93+
config=config):
94+
MainWindow.main()
95+
except:
96+
MainWindow.main()
97+
98+
99+
try:
100+
if '-analysis' in sys.argv:
101+
do_analysis()
102+
else:
103+
from Widgets import MainWindow
104+
MainWindow.main()
78105
except SystemExit:
79106
pass
80107
except:

0 commit comments

Comments
 (0)