Author: tmckay
Date: 2011-01-23 18:49:58 +0000 (Sun, 23 Jan 2011)
New Revision: 4481
Modified:
branches/scale_testing/mech_scripts/test_driver.py
Log:
Tweak reporting
Modified: branches/scale_testing/mech_scripts/test_driver.py
===================================================================
--- branches/scale_testing/mech_scripts/test_driver.py 2011-01-23 00:30:31 UTC (rev 4480)
+++ branches/scale_testing/mech_scripts/test_driver.py 2011-01-23 18:49:58 UTC (rev 4481)
@@ -20,6 +20,7 @@
class Transaction(object):
def __init__(self):
self.custom_timers = {}
+ self.stand_alone_stats = {}
self.http_date_gmt = "%a, %d %b %Y %H:%M:%S GMT"
self.headers = {}
@@ -34,7 +35,7 @@
def next_file(self):
if not self.file_init:
- self.link_init = True
+ self.file_init = True
if os.path.isdir(self.link_file):
self.file_list = os.listdir(self.link_file)
for i in range(len(self.file_list)):
@@ -56,15 +57,19 @@
parser.add_option('--machine', dest='machine',
type='str', default="localhost:45672")
parser.add_option('--file', dest='file',
type='str', default="")
parser.add_option('--iter', dest='iter',
type='int', default=0)
+ parser.add_option('--info', dest='info',
action="store_true", default=False)
if type(self.script_options) == str:
self.script_options = self.script_options.split()
opts, args = parser.parse_args(self.script_options)
self.machine = opts.machine
self.link_file = os.path.abspath(opts.file)
self.iteration_limit = opts.iter
+ self.print_info = opts.info
start_timer = time_time()
f = open(self.next_file(), "r")
+ if self.print_info:
+ print f
# If an iteration limit was set, bail after going through file list
# that many times
@@ -72,6 +77,7 @@
return True
total_gets = 0
+ total_size = 0
get_latency = 0
for link in f:
link_info = link.split(',')
@@ -93,29 +99,46 @@
else:
conn.request('GET', link)
resp = conn.getresponse()
+ data = resp.read()
if resp.status == 200:
self.visited[link] = datetime.utcnow().strftime(self.http_date_gmt)
- print "Link " + link
+ if self.print_info:
+ print "Link " + link + ", " +
str(len(data)/1024)
elif resp.status == 304:
- pass
- print ("already visited", link)
+ if self.print_info:
+ print ("already visited", link)
else:
- print ("other status", resp.status, link)
self.visited[link] = None
+ if self.print_info:
+ print ("other status", resp.status, link)
get_latency += time_time() - time_for_get
total_gets += 1
+ total_size += len(data)
latency = time_time() - start_timer
self.custom_timers['Page File'] = latency
self.custom_timers['Avg Get'] = get_latency / total_gets
- self.custom_timers['Total Gets'] = total_gets
-
+ self.stand_alone_stats['Total Gets'] = total_gets
+ self.stand_alone_stats['Total Size kb'] = total_size / 1024
except Exception, e:
traceback.print_exc()
if __name__ == '__main__':
trans = Transaction()
trans.script_options=sys.argv[1:]
+ avg_pg_file = 0
+ avg_get = 0
+ avg_num_get = 0
+ avg_kb =0
+ samples = 0
while not trans.run():
- print trans.custom_timers
+ samples += 1
+ avg_pg_file += trans.custom_timers['Page File']
+ avg_get += trans.custom_timers['Avg Get']
+ avg_num_get += trans.stand_alone_stats['Total Gets']
+ avg_kb += trans.stand_alone_stats['Total Size kb']
+ print "page: ", avg_pg_file / samples, \
+ "get:", avg_get / samples, "num_get:", avg_num_get /samples,
"kb:", avg_kb / samples
+ #print trans.custom_timers
+ #print trans.stand_alone_stats
Show replies by date