summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorjola-mirecka <jola.mirecka@hp.com>2013-09-04 19:32:09 +0100
committerDarrell Bishop <darrell@swiftstack.com>2013-11-28 13:02:54 -0500
commit9b7e24c4499c248995d09ea99b46d1678f7a3afb (patch)
treea3fe30b34e100e1c6e478070eb7530246e468675 /bin
parenta253b5cecd95137069bdf40e4b18abada6f15a22 (diff)
downloadpython-swiftclient-9b7e24c4499c248995d09ea99b46d1678f7a3afb.tar.gz
Fix download bandwidth for swift command.
We noticed a difference in download bandwidth while using authentication details and pre-auth information for download. Download using authentication details included authentication time into the download bandwidth at each call of the function. This time should have been excluded from download bandwidth. This patch set is adding a timer variable to the client library. That allows to accurately measure and store the time of each action. Then while printing the download bandwith in the swift command authentication time is excluded from bandwidth. Change-Id: I63df9023e169f637f120ae9e25dac9c90a4e75a0 Fixes: bug #1197443
Diffstat (limited to 'bin')
-rwxr-xr-xbin/swift20
1 files changed, 13 insertions, 7 deletions
diff --git a/bin/swift b/bin/swift
index eb42c13..b61f47d 100755
--- a/bin/swift
+++ b/bin/swift
@@ -331,7 +331,7 @@ def st_download(parser, args, thread_manager):
headers, body = \
conn.get_object(container, obj, resp_chunk_size=65536,
headers=req_headers)
- header_receipt = time()
+ headers_receipt = time()
content_type = headers.get('content-type')
if 'content-length' in headers:
content_length = int(headers.get('content-length'))
@@ -391,9 +391,14 @@ def st_download(parser, args, thread_manager):
utime(path, (mtime, mtime))
if options.verbose:
finish_time = time()
- time_str = 'headers %.3fs, total %.3fs, %.3f MB/s' % (
- header_receipt - start_time, finish_time - start_time,
- float(read_length) / (finish_time - start_time) / 1000000)
+ auth_time = conn.auth_end_time - start_time
+ headers_receipt = headers_receipt - start_time
+ total_time = finish_time - start_time
+ download_time = total_time - auth_time
+ time_str = ('auth %.3fs, headers %.3fs, total %.3fs, '
+ '%.3f MB/s' % (
+ auth_time, headers_receipt, total_time,
+ float(read_length) / download_time / 1000000))
if conn.attempts > 1:
thread_manager.print_msg('%s [%s after %d attempts]', path,
time_str, conn.attempts)
@@ -460,9 +465,10 @@ def st_download(parser, args, thread_manager):
thread_manager.error('Account not found')
elif len(args) == 1:
if '/' in args[0]:
- print >> stderr, ('WARNING: / in container name; you '
- 'might have meant %r instead of %r.' % (
- args[0].replace('/', ' ', 1), args[0]))
+ print >> stderr, (
+ 'WARNING: / in container name; you might have meant '
+ '%r instead of %r.' % (
+ args[0].replace('/', ' ', 1), args[0]))
container_queue.put((args[0], object_queue, options.prefix))
else:
if len(args) == 2: