From ee943d69b99b562c596c6c55e2aa1c445b4a80ef Mon Sep 17 00:00:00 2001 From: Jacob Champion Date: Fri, 4 Dec 2015 12:51:26 -0800 Subject: [PATCH] Don't count statistics for failed connections Failed connection items often show up in the result JSON with junk data (zero or negative timing values, etc.), which throws off the overall statistics. Don't add a connection's stats to the overall Result unless that connection succeeded. --- analyze.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/analyze.py b/analyze.py index 7037021..2a77cfc 100644 --- a/analyze.py +++ b/analyze.py @@ -99,23 +99,41 @@ def load(filename): if prefix == 'ended': res.ended = value + if (prefix, event) == ('connection_stats.item', 'start_map'): + # Start of a new connection. + conn_failed = False + conn_pre_init = None + conn_open = None + conn_close = None + if prefix == 'connection_stats.item.tcp_pre_init': - if res.preInitMin is None or value < res.preInitMin: - res.preInitMin = value - if res.preInitMax is None or value > res.preInitMax: - res.preInitMax = value + conn_pre_init = value if prefix == 'connection_stats.item.failed': if value: + conn_failed = True res.fail += 1 else: res.success += 1 if prefix == 'connection_stats.item.open': - res.openTimestamps.append(value) + conn_open = value if prefix == 'connection_stats.item.close': - res.closeTimestamps.append(value) + conn_close = value + + if (prefix, event) == ('connection_stats.item', 'end_map'): + # End of a connection. Only save its statistics if it succeeded. + # XXX This assumes that the open/close/tcp_pre_init values are always + # defined by each connection object. + if not conn_failed: + if res.preInitMin is None or conn_pre_init < res.preInitMin: + res.preInitMin = conn_pre_init + if res.preInitMax is None or conn_pre_init > res.preInitMax: + res.preInitMax = conn_pre_init + + res.openTimestamps.append(conn_open) + res.closeTimestamps.append(conn_close) res.total = res.success + res.fail res.durationWallclock = res.ended - res.started