2 To use this, get a trace file such as this one:
4 wget http://tahoe-lafs.org/trac/tahoe-lafs/raw-attachment/ticket/1170/run-112-above28-flog-dump-sh8-on-nsziz.txt
6 And run this command passing that trace file's name:
8 python bench_spans.py run-112-above28-flog-dump-sh8-on-nsziz.txt
11 from pyutil import benchutil
13 from allmydata.util.spans import DataSpans
17 DUMP_S='_received spans trace .dump()'
18 GET_R=re.compile('_received spans trace .get\(([0-9]*), ([0-9]*)\)')
19 POP_R=re.compile('_received spans trace .pop\(([0-9]*), ([0-9]*)\)')
20 REMOVE_R=re.compile('_received spans trace .remove\(([0-9]*), ([0-9]*)\)')
21 GET_SPANS_S='_received spans trace .get_spans()'
22 ADD_R=re.compile('_received spans trace .add\(([0-9]*), len=([0-9]*)\)')
23 INIT_S='_received spans trace = DataSpans'
26 def __init__(self, inf):
35 inline = self.inf.readline()
37 while count < N and inline != '':
40 # self.stats['dump'] = self.stats.get('dump', 0) + 1
41 elif GET_SPANS_S in inline:
43 # self.stats['get_spans'] = self.stats.get('get_spans', 0) + 1
44 elif ADD_R.search(inline):
45 mo = ADD_R.search(inline)
46 start = int(mo.group(1))
47 length = int(mo.group(2))
48 self.s.add(start, 'x'*length)
49 # self.stats['add'] = self.stats.get('add', 0) + 1
50 elif GET_R.search(inline):
51 mo = GET_R.search(inline)
52 start = int(mo.group(1))
53 length = int(mo.group(2))
54 self.s.get(start, length)
55 # self.stats['get'] = self.stats.get('get', 0) + 1
56 elif REMOVE_R.search(inline):
57 mo = REMOVE_R.search(inline)
58 start = int(mo.group(1))
59 length = int(mo.group(2))
60 self.s.remove(start, length)
61 # self.stats['remove'] = self.stats.get('remove', 0) + 1
62 elif POP_R.search(inline):
63 mo = POP_R.search(inline)
64 start = int(mo.group(1))
65 length = int(mo.group(2))
66 self.s.pop(start, length)
67 # self.stats['pop'] = self.stats.get('pop', 0) + 1
68 elif INIT_S in inline:
71 print "Warning, didn't recognize this line: %r" % (inline,)
73 inline = self.inf.readline()
77 benchutil.print_bench_footer(UNITS_PER_SECOND=1000000)
78 print "(microseconds)"
80 for N in [600, 6000, 60000]:
81 b = B(open(sys.argv[1], 'rU'))
83 benchutil.rep_bench(b.run, N, b.init, UNITS_PER_SECOND=1000000)