From 4ede2f126a1b753d7a56dea67e0e098441d4ff23 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Tue, 13 Aug 2013 15:35:33 -0700 Subject: [PATCH 1/3] utils: Add missing "B" for pretty_size() * Add missing unit for megabytes, should print "MB". --- libmproxy/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 258626dbb..961c6618b 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -74,7 +74,7 @@ def pretty_size(size): suffixes = [ ("B", 2**10), ("kB", 2**20), - ("M", 2**30), + ("MB", 2**30), ] for suf, lim in suffixes: if size >= lim: From ea28496beab48a1fcca58184b73b24af491d4704 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Tue, 13 Aug 2013 12:02:49 -0700 Subject: [PATCH 2/3] console: Add support for displaying elapsed time * Display the elapsed time in the the response row. * Very handy for passive performance analysis. --- libmproxy/console/common.py | 9 ++++++++- libmproxy/console/palettes.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 187a755f0..90a23eaaa 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -144,6 +144,9 @@ def raw_format_flow(f, focus, extended, padding): if f["resp_ctype"]: resp.append(fcol(f["resp_ctype"], rc)) resp.append(fcol(f["resp_clen"], rc)) + + resp.append(fcol(f["resp_et"], "time")) + elif f["err_msg"]: resp.append(fcol(SYMBOL_RETURN, "error")) resp.append( @@ -185,11 +188,15 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2): contentdesc = "[content missing]" else: contentdesc = "[no content]" + + delta = f.response.timestamp_end - f.request.timestamp_start + d.update(dict( resp_code = f.response.code, resp_is_replay = f.response.is_replay(), resp_acked = f.response.reply.acked, - resp_clen = contentdesc + resp_clen = contentdesc, + resp_et = "{0:2.0f}ms".format(delta * 1000), )) t = f.response.headers["content-type"] if t: diff --git a/libmproxy/console/palettes.py b/libmproxy/console/palettes.py index 650cf2618..df84a1e4f 100644 --- a/libmproxy/console/palettes.py +++ b/libmproxy/console/palettes.py @@ -35,6 +35,7 @@ palettes = { ('header', 'dark cyan', 'default'), ('highlight', 'white,bold', 'default'), + ('time', 'light red', 'default'), ('intercept', 'brown', 'default', None, '#f60', 'default'), ('replay', 'light green', 'default', None, '#0f0', 'default'), ('ack', 'light red', 'default'), From 41041159f6d9b260d0d1c95d42b1dd4f14b7f0cb Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Tue, 13 Aug 2013 16:29:57 -0700 Subject: [PATCH 3/3] console: Add support for displaying transfer rate * Display the rate in the the response row. * Very handy for passive performance analysis. --- libmproxy/console/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 90a23eaaa..748302377 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -146,6 +146,7 @@ def raw_format_flow(f, focus, extended, padding): resp.append(fcol(f["resp_clen"], rc)) resp.append(fcol(f["resp_et"], "time")) + resp.append(fcol(f["resp_rate"], "highlight")) elif f["err_msg"]: resp.append(fcol(SYMBOL_RETURN, "error")) @@ -190,6 +191,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2): contentdesc = "[no content]" delta = f.response.timestamp_end - f.request.timestamp_start + rate = utils.pretty_size(len(f.response.content) / delta) d.update(dict( resp_code = f.response.code, @@ -197,6 +199,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2): resp_acked = f.response.reply.acked, resp_clen = contentdesc, resp_et = "{0:2.0f}ms".format(delta * 1000), + resp_rate = "{0}/s".format(rate), )) t = f.response.headers["content-type"] if t: