diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2014-09-05 02:00:36 -0500 |
|---|---|---|
| committer | lin-hua-cheng <os.lcheng@gmail.com> | 2015-04-07 23:53:31 -0700 |
| commit | 0d689871b4d8c060e1d48a9472449f3d670333bb (patch) | |
| tree | cdef140b5a66875ddbd9ff0ea7a561b5e2ec2b3a /openstackclient/common/timing.py | |
| parent | a9d1e3d2192aa965d15c89eb6a603faf2e95b7ec (diff) | |
| download | python-openstackclient-0d689871b4d8c060e1d48a9472449f3d670333bb.tar.gz | |
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
Diffstat (limited to 'openstackclient/common/timing.py')
| -rw-r--r-- | openstackclient/common/timing.py | 10 |
1 files changed, 6 insertions, 4 deletions
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, |
