From: zooko Date: Sat, 13 Sep 2008 11:50:21 +0000 (+0530) Subject: setup: add some scripts to benchmark zfec with different stride lengths X-Git-Url: https://git.rkrishnan.org/%5B/frontends/flags/cyclelanguage?a=commitdiff_plain;h=60bc1e172e65281027024ef0aac9ca6efb033321;p=tahoe-lafs%2Fzfec.git setup: add some scripts to benchmark zfec with different stride lengths darcs-hash:8b791eeeff1174f795a2da32eac5e4189c1aeb47 --- diff --git a/zfec/bench/bench_zfec.py b/zfec/bench/bench_zfec.py index 9ddec17..30b847c 100644 --- a/zfec/bench/bench_zfec.py +++ b/zfec/bench/bench_zfec.py @@ -75,7 +75,7 @@ def bench(): # for f in [_encode_file_not_really, _encode_file_not_really_and_hash, _encode_file, _encode_file_and_hash,]: # for f in [_encode_data_not_really, _encode_data_easyfec, _encode_data_fec,]: for f in [_encode_data_fec,]: - print f - benchutil.bench(f, initfunc=_make_new_rand_data, TOPXP=24, MAXREPS=256, MAXTIME=64) + for BSIZE in [2**22]: + benchutil.rep_bench(f, n=BSIZE, initfunc=_make_new_rand_data, MAXREPS=64, MAXTIME=None) bench() diff --git a/zfec/setup.py b/zfec/setup.py index 8d86f2f..7e956af 100755 --- a/zfec/setup.py +++ b/zfec/setup.py @@ -129,8 +129,8 @@ setup(name=PKG, url='http://allmydata.org/trac/'+PKG, license='GNU GPL', dependency_links=dependency_links, - install_requires=["argparse >= 0.8", "pyutil >= 1.3.5"], - tests_require=["pyutil >= 1.3.5"], + install_requires=["argparse >= 0.8", "pyutil >= 1.3.19"], + tests_require=["pyutil >= 1.3.19"], packages=find_packages(), include_package_data=True, data_files=data_files, diff --git a/zfec/stridetune-bench.ba.sh b/zfec/stridetune-bench.ba.sh new file mode 100755 index 0000000..01555ca --- /dev/null +++ b/zfec/stridetune-bench.ba.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +/bin/rm -rf ./benchresults +mkdir benchresults +STRIDE=32 +while [ $(( $STRIDE < 32769 )) ] ; do + /bin/rm -rf build + rm zfec/_fec.so + /bin/rm -rf instdir + mkdir instdir + PYTHONPATH=instdir ./setup.py develop --install-dir=instdir --stride=${STRIDE} >/dev/null + echo $STRIDE + PYTHONPATH=instdir python -OO ./bench/bench_zfec.py >> benchresults/comp_0-stride_$STRIDE + tail -1 benchresults/comp_0-stride_$STRIDE + STRIDE=$(( $STRIDE + 32 )) +done diff --git a/zfec/stridetune-bench.py b/zfec/stridetune-bench.py new file mode 100755 index 0000000..02c13e1 --- /dev/null +++ b/zfec/stridetune-bench.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import bisect, random, os, re + +from pyutil import fileutil + +assert not os.path.exists("benchresults") + +os.mkdir("benchresults") + +MIN=512 +MAX=1024 + +results = {} + +R=re.compile("ave rate: ([1-9][0-9]*)") + +def measure(stride): + fileutil.rm_dir("build") + fileutil.rm_dir("instdir") + fileutil.remove_if_possible(os.path.join("zfec", "_fec.so")) + fileutil.make_dirs("instdir") + fname = os.path.join("benchresults", "comp_0-stride_%d"%stride) + os.system("PYTHONPATH=instdir ./setup.py develop --install-dir=instdir --stride=%d >/dev/null" % stride) + os.system("PYTHONPATH=instdir python -OO ./bench/bench_zfec.py >> %s" % fname) + inf = open(fname, "rU") + for l in inf: + m = R.search(l) + if m: + result = int(m.group(1)) + if results.has_key(stride): + print "stride: %d, results: %d (dup %d)" % (stride, result, results[stride]) + else: + print "stride: %d, results: %d" % (stride, result) + results[stride] = result + break + +measure(MIN) +measure(MAX) + +while True: + stride = random.randrange(MIN, MAX+1) + measure(stride) diff --git a/zfec/stridetune-dat.bash b/zfec/stridetune-dat.bash new file mode 100755 index 0000000..b250bff --- /dev/null +++ b/zfec/stridetune-dat.bash @@ -0,0 +1,10 @@ +#!/bin/bash + +DAT=stridetune.dat +rm -f $DAT +for F in benchresults/comp_0-stride_*; do + NUM=${F:27} + for M in `grep "^N: " benchresults/comp_0-stride_$NUM | cut -d':' -f10-` ; do + echo "$NUM $M" >> $DAT + done +done diff --git a/zfec/stridetune-graph.py b/zfec/stridetune-graph.py new file mode 100755 index 0000000..7025989 --- /dev/null +++ b/zfec/stridetune-graph.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from pyx import * +def g(f): + g=graph.graphxy(width=16, x=graph.axis.linear(), y=graph.axis.linear()) + + g.plot([graph.data.file(f, x=1, y=2)]) + g.writeEPSfile(f+'.eps') + +g('stridetune.dat')