Add an option to dump profiling data
This commit is contained in:
parent
c0a9e75c63
commit
eaa6c7656a
@ -83,9 +83,17 @@ def option_parser():
|
|||||||
a('--exec', '-e', dest='child', default=pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh', help=_('Run the specified command instead of the shell'))
|
a('--exec', '-e', dest='child', default=pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh', help=_('Run the specified command instead of the shell'))
|
||||||
a('-d', '--directory', default='.', help=_('Change to the specified directory when launching'))
|
a('-d', '--directory', default='.', help=_('Change to the specified directory when launching'))
|
||||||
a('--version', action='version', version='{} {} by Kovid Goyal'.format(appname, '.'.join(str_version)))
|
a('--version', action='version', version='{} {} by Kovid Goyal'.format(appname, '.'.join(str_version)))
|
||||||
|
a('--profile', action='store_true', default=False, help=_('Show profiling data after exit'))
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def run_app():
|
||||||
|
try:
|
||||||
|
return QApplication.instance().exec_()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = option_parser().parse_args()
|
args = option_parser().parse_args()
|
||||||
if args.cmd:
|
if args.cmd:
|
||||||
@ -105,7 +113,13 @@ def main():
|
|||||||
raise SystemExit(str(err)) from None
|
raise SystemExit(str(err)) from None
|
||||||
w = MainWindow(opts)
|
w = MainWindow(opts)
|
||||||
w.show()
|
w.show()
|
||||||
try:
|
if args.profile:
|
||||||
app.exec_()
|
import cProfile
|
||||||
except KeyboardInterrupt:
|
pr = cProfile.Profile()
|
||||||
pass
|
pr.enable()
|
||||||
|
ret = run_app()
|
||||||
|
pr.print_stats('cumtime')
|
||||||
|
pr.disable()
|
||||||
|
else:
|
||||||
|
ret = run_app()
|
||||||
|
return ret
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user