From 0d689871b4d8c060e1d48a9472449f3d670333bb Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 5 Sep 2014 02:00:36 -0500 Subject: Fix session timing Subclass keystoneclient.session.Session to add the timing hooks to record the elapsed time returned by requests.Response objects, including the redirection history. Redirects are included individually and not rolled into the total time for the original request. This works for all clients that use OSC's session. Closes-Bug: #1402577 Change-Id: I9360c90c151579b89a37edb8c11c17feb15b3cb9 --- openstackclient/common/timing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'openstackclient/common/timing.py') diff --git a/openstackclient/common/timing.py b/openstackclient/common/timing.py index 1c94682c..d13c86e7 100644 --- a/openstackclient/common/timing.py +++ b/openstackclient/common/timing.py @@ -33,10 +33,12 @@ class Timing(lister.Lister): results = [] total = 0.0 - for url, start, end in self.app.timing_data: - seconds = end - start - total += seconds - results.append((url, seconds)) + for url, td in self.app.timing_data: + # NOTE(dtroyer): Take the long way here because total_seconds() + # was added in py27. + sec = (td.microseconds + (td.seconds + td.days*86400) * 1e6) / 1e6 + total += sec + results.append((url, sec)) results.append(('Total', total)) return ( column_headers, -- cgit v1.2.1