#!/usr/bin/python2.5 """ This tool is used for driving and recording load testing with [Siege][siege], rather than implementing the load testing code itself. [siege]: http://www.joedog.org/index/siege-home """ import os, subprocess, pickle, time addr = 'http://67.207.149.179:8080/grouped_faq/' #addr = 'http://67.207.149.179:8080/' delay = 1 requests = 10 trials = 3 # number of trials per test pause = 30 # seconds between tests try: fin = open('results.log','r') results = pickle.loads(fin.read()) fin.close() except IOError: results = [] for i in xrange(25,225,25): for j in xrange(trials): dict = {} dict['delay'] = delay dict['requests'] = requests dict['users'] = i cmd = "siege -d%s -r%s -c%s %s" % (delay, i, requests, addr) proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() for line in stderr.split('\n'): if not line.startswith('**'): parts = [x.strip() for x in line.split(':')] if len(parts) > 1: dict[parts[0]] = parts[1] results.append(dict) time.sleep(pause) fout = open('results.log','w') fout.write(pickle.dumps(results)) fout.close()