forked from KarolBedkowski/wxgtd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxgtd_dbg.py
executable file
·66 lines (55 loc) · 1.53 KB
/
wxgtd_dbg.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" Startup application in debug mode.
Copyright (c) Karol Będkowski, 2013
This file is part of wxGTD
Licence: GPLv2+
"""
__author__ = "Karol Będkowski"
__copyright__ = "Copyright (c) Karol Będkowski, 2013"
__version__ = "2013-04-27"
import sys
if '--profile' not in sys.argv:
sys.argv.append('-d')
def _profile():
""" profile app """
import cProfile
print 'Profiling....'
cProfile.run('from wxgtd.main import run; run()', 'profile.tmp')
import pstats
import time
with open('profile_result_%d.txt' % int(time.time()), 'w') as out:
stat = pstats.Stats('profile.tmp', stream=out)
#s.strip_dirs()
stat.sort_stats('cumulative').print_stats('wxgtd', 50)
out.write('\n\n----------------------------\n\n')
stat.sort_stats('time').print_stats('wxgtd', 50)
out.write('\n\n============================\n\n')
stat.sort_stats('cumulative').print_stats('', 50)
out.write('\n\n----------------------------\n\n')
stat.sort_stats('time').print_stats('', 50)
def _memprofile():
""" mem profile app """
from wxgtd.main import run
run()
import gc
gc.collect()
while gc.collect() > 0:
print 'collect'
import objgraph
objgraph.show_most_common_types(20)
import pdb
pdb.set_trace()
if __name__ == "__main__":
if '--profile' in sys.argv:
sys.argv.remove('--profile')
_profile()
elif '--memprofile' in sys.argv:
sys.argv.remove('--memprofile')
_memprofile()
elif '--version' in sys.argv:
from wxgtd import version
print version.INFO
else:
from wxgtd.main import run
run()