setup: add some scripts to benchmark zfec with different stride lengths
authorzooko <zooko@zooko.com>
Sat, 13 Sep 2008 11:50:21 +0000 (17:20 +0530)
committerzooko <zooko@zooko.com>
Sat, 13 Sep 2008 11:50:21 +0000 (17:20 +0530)
darcs-hash:8b791eeeff1174f795a2da32eac5e4189c1aeb47

zfec/bench/bench_zfec.py
zfec/setup.py
zfec/stridetune-bench.ba.sh [new file with mode: 0755]
zfec/stridetune-bench.py [new file with mode: 0755]
zfec/stridetune-dat.bash [new file with mode: 0755]
zfec/stridetune-graph.py [new file with mode: 0755]

index 9ddec17dac5ee185fb0341c25e805707fed203ab..30b847c5be34699cc3537b6b78b229da9609d6af 100644 (file)
@@ -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()
index 8d86f2fb1e655310d0853784565b6d5d6b1c859e..7e956af1a67cc44c518f0c612ebbe4505a4425d4 100755 (executable)
@@ -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 (executable)
index 0000000..01555ca
--- /dev/null
@@ -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 (executable)
index 0000000..02c13e1
--- /dev/null
@@ -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 (executable)
index 0000000..b250bff
--- /dev/null
@@ -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 (executable)
index 0000000..7025989
--- /dev/null
@@ -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')