From 3a78c95d0a202b486d062951ee0593f43a16eac2 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Thu, 26 Feb 2015 18:14:20 -0300 Subject: added to flowlist / flowdetail time elapsed between request sent and response received --- libmproxy/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libmproxy/utils.py') diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 33af035f..76e99c34 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -79,6 +79,18 @@ def pretty_size(size): x = int(x) return str(x) + suf +def pretty_duration(secs): + formatters = [ + (100, "{:.0f}s"), + (10, "{:2.1f}s"), + (1, "{:1.2f}s"), + ] + + for limit, formatter in formatters: + if secs >= limit: + return formatter.format(secs) + #less than 1 sec + return "{:.0f}ms".format(secs*1000) class Data: def __init__(self, name): -- cgit v1.2.3