7
def do_ab_call(url,nthreads,reqs):
8
cmd="ab -k -c %d -n %d '%s'" % (nthreads,reqs,url)
11
ret = commands.getoutput(cmd)
12
sList = ret.split(os.linesep)
13
for i, line in enumerate(sList):
14
if re.match("Requests per second", line) is not None:
16
summary['reqspersec']=val[3]
17
if re.match("Document Length", line) is not None:
19
summary['size']=val[2]
22
base="http://localhost:8081"
23
params="LAYERS=test,test3&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-2.8125,47.8125,0,50.625&WIDTH=256&HEIGHT=256"
30
urls['tilecache']="%s/%s?%s" % (base,'tilecache',params)
31
urls['mapcache best compression']="%s/%s?%s" % (base,'mapcache-best',params)
32
urls['mapcache default compression']="%s/%s?%s" % (base,'mapcache-default',params)
33
urls['mapcache fast compression']="%s/%s?%s" % (base,'mapcache-fast',params)
34
urls['mapcache png quantization']="%s/%s?%s" % (base,'mapcache-pngq',params)
35
#urls['mapproxy']="http://localhost:8080/service?%s" % (params)
37
plotfile = open("%s.plot"%(filebase),"w")
38
datafile = open("%s.dat"%(filebase),"w")
40
plotfile.write("set terminal pdf\nset key autotitle columnhead\nset output \"%s.pdf\"\nset style data lines\n"%(filebase))
41
plotfile.write("set xlabel \"concurrent requests\"\n")
42
plotfile.write("set ylabel \"throughput (requests/sec)\"\n")
43
plotfile.write("set title \"%s\"\n"%(title))
45
for title,url in urls.iteritems():
47
plotfile.write("plot \"%s.dat\" using 2:xticlabel(1) index 0"%(filebase))
49
plotfile.write(",\"\" using 2 index %d"%(count))
51
for nthreads in [1,2,3,4]:
52
reqs = min(nthreads,4) * nreqs
53
res = do_ab_call(url,nthreads,reqs)
55
datafile.write("\n\nthreads \"%s (%s bytes)\"\n"%(title,res['size']))
56
datafile.write("%d %s\n"%(nthreads,res['reqspersec']))