Add some debugging output to help troubleshoot a performance problem.

This commit is contained in:
Aldo Cortesi 2011-03-27 13:10:06 +13:00
parent c0bd1a39e4
commit c3105153a5
2 changed files with 12 additions and 0 deletions

View File

@ -651,6 +651,9 @@ class StatusBar(WWrap):
if opts:
r.append("[%s]"%(":".join(opts)))
if self.master.debug:
r.append("[lt:%0.3f]"%self.master.looptime)
return r
def redraw(self):
@ -767,6 +770,7 @@ class Options(object):
__slots__ = [
"anticache",
"client_replay",
"debug",
"keepserving",
"kill",
"intercept",
@ -809,6 +813,7 @@ class ConsoleMaster(flow.FlowMaster):
]
def __init__(self, server, options):
flow.FlowMaster.__init__(self, server, ConsoleState())
self.looptime = 0
self.conn_list_view = None
self.set_palette()
@ -849,6 +854,9 @@ class ConsoleMaster(flow.FlowMaster):
if options.server_replay:
self.server_playback_path(options.server_replay)
self.debug = options.debug
def _runscript(self, f, path):
path = os.path.expanduser(path)
self.state.last_script = path
@ -1292,6 +1300,7 @@ class ConsoleMaster(flow.FlowMaster):
slave.start()
try:
while not controller.exit:
startloop = time.time()
self.statusbar.redraw()
size = self.drawscreen()
self.tick(q)
@ -1427,6 +1436,7 @@ class ConsoleMaster(flow.FlowMaster):
k = None
if k:
self.view.keypress(size, k)
self.looptime = time.time() - startloop
except (Stop, KeyboardInterrupt):
pass

View File

@ -27,6 +27,7 @@ if __name__ == '__main__':
version="%%prog %s"%VERSION,
)
cmdline.common_options(parser)
parser.add_option("--debug", dest="debug", default=False, action="store_true")
group = OptionGroup(
@ -57,6 +58,7 @@ if __name__ == '__main__':
opts = console.Options(**cmdline.get_common_options(options))
opts.intercept = options.intercept
opts.limit = options.limit
opts.debug = options.debug
m = console.ConsoleMaster(server, opts)
for i in args: