-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPROFILING
More file actions
41 lines (31 loc) · 1.35 KB
/
PROFILING
File metadata and controls
41 lines (31 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
To profile MyData, yappi is recommended:
https://pypi.python.org/pypi/yappi
Make the following patch (#1) to mydata/views/mydata.py:
At the end of the "OnClose" method, add:
event.Skip()
self.taskBarIcon.Destroy()
and comment out the "event.StopPropagation()" earlier in the "OnClose" method.
which will allow the EVT_CLOSE event to propagate to the point where wxPython
knows that all of its top level windows have been closed, so it can end its
main loop without exiting out of the Python shell.
Then run the following:
import yappi
yappi.start()
from mydata import MyData
MyData.Run(argv=[''])
# Interact with MyData's GUI, open its main window,
# and run time-consuming tasks. Then close MyData's
# main window, having made patch #1
yappi.get_thread_stats().print_all()
yappi.get_func_stats().print_all()
# Sort output by time spent in each function excluding
# calls to subroutines ('tsub'), listing the most
# time-consuming functions at the bottom, so you don't
# need to scroll back:
yappi.get_func_stats().sort('tsub', 'asc').print_all()
To re-run profiling, exit and relaunch Python before re-running yappi and
MyData.
On Linux, get_thread_stats() won't display the thread names. If you want
to see thread names in yappi output on Linux, you can achieve this with
the python-prctl package, but the get_func_stats() output is generally
more useful.