File: stridetune-bench.py

package info (click to toggle)
zfec 1.5.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 524 kB
  • sloc: python: 2,022; ansic: 892; haskell: 229; sh: 22; makefile: 4
file content (43 lines) | stat: -rwxr-xr-x 1,161 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)