Rev 15: Allow individual fixture selection. in http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk
Robert Collins
robertc at robertcollins.net
Wed Jul 2 10:31:16 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk
------------------------------------------------------------
revno: 15
revision-id: robertc at robertcollins.net-20080702093116-q5iu1k5bpd7icqlk
parent: robertc at robertcollins.net-20080702085603-pcd6iimxvyji6wtd
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Wed 2008-07-02 19:31:16 +1000
message:
Allow individual fixture selection.
modified:
indexbench.py indexbench.py-20080702083855-5tju02y79rw7kkzh-1
=== modified file 'indexbench.py'
--- a/indexbench.py 2008-07-02 08:56:03 +0000
+++ b/indexbench.py 2008-07-02 09:31:16 +0000
@@ -12,7 +12,7 @@
from bzrlib.knit import _KnitGraphIndex, KnitVersionedFiles
from bzrlib.graph import Graph
from bzrlib.commands import Command
-from bzrlib.option import Option
+from bzrlib.option import Option, ListOption
key_count = 0
@@ -40,7 +40,7 @@
def time_index(names, source, factory, builder, target, label, name_keys,
- text_keys, use_drop_cache):
+ text_keys, use_drop_cache, fixtures):
if use_drop_cache:
drop_cache = drop_caches
else:
@@ -63,79 +63,84 @@
finish = time.time()
print "%s: Wrote %d bytes in %0.3f" % (label, length, finish - now - read_time)
# iter_all
- drop_cache()
- now = time.time()
- for name, index in iter_indices(names, target, factory):
- for item in index.iter_all_entries():
- pass
- finish = time.time()
- print "%s: iter_all_entries in %0.3f" % (label, finish - now)
+ if 'all' in fixtures:
+ drop_cache()
+ now = time.time()
+ for name, index in iter_indices(names, target, factory):
+ for item in index.iter_all_entries():
+ pass
+ finish = time.time()
+ print "%s: iter_all_entries in %0.3f" % (label, finish - now)
# random shuffle, all keys (name_keys comes preshuffled)
- drop_cache()
- now = time.time()
- for name, index in iter_indices(names, target, factory):
- order = name_keys[name]
- shuffle(order)
- for key in order:
- index.iter_entries([key]).next()
- finish = time.time()
- print "%s: iter_random_one in %0.3f" % (label, finish - now)
+ if 'shuffle' in fixtures:
+ drop_cache()
+ now = time.time()
+ for name, index in iter_indices(names, target, factory):
+ order = name_keys[name]
+ shuffle(order)
+ for key in order:
+ index.iter_entries([key]).next()
+ finish = time.time()
+ print "%s: iter_random_one in %0.3f" % (label, finish - now)
# text extraction simulation (follow a compression graph) for text_keys
- text_names = [name for name in names if name.endswith('.tix')]
- text_indices = [index for name, index in iter_indices(text_names, target, factory)]
- text_index = CombinedGraphIndex(text_indices)
- btree_index.bloom_hits = 0
- drop_cache()
- now = time.time()
- # VersionedFiles can do multi-key extraction, so we can use that.
-
- index = _KnitGraphIndex(text_index, lambda:True, deltas=True, parents=True)
- vf = KnitVersionedFiles(index, None)
- vf._get_components_positions(text_keys)
- finish = time.time()
- print "%s: get_components_positions(%d) in %0.3f, bloom(%d)" % (label, len(text_keys),
- finish - now, btree_index.bloom_hits)
+ if 'text' in fixtures:
+ text_names = [name for name in names if name.endswith('.tix')]
+ text_indices = [index for name, index in iter_indices(text_names, target, factory)]
+ text_index = CombinedGraphIndex(text_indices)
+ btree_index.bloom_hits = 0
+ drop_cache()
+ now = time.time()
+ # VersionedFiles can do multi-key extraction, so we can use that.
+
+ index = _KnitGraphIndex(text_index, lambda:True, deltas=True, parents=True)
+ vf = KnitVersionedFiles(index, None)
+ vf._get_components_positions(text_keys)
+ finish = time.time()
+ print "%s: get_components_positions(%d) in %0.3f, bloom(%d)" % (label, len(text_keys),
+ finish - now, btree_index.bloom_hits)
# follow a revision graph
- rev_names = [name for name in names if name.endswith('.rix')]
- rev_indices = [index for name, index in iter_indices(rev_names, target, factory)]
- rev_index = CombinedGraphIndex(rev_indices)
- # pick the lexograph middle revision, just because.
- all_revs = sorted(node[1] for node in rev_index.iter_all_entries())
- revid = all_revs[len(all_revs)/2]
- # reopen indices
- rev_indices = [index for name, index in iter_indices(rev_names, target, factory)]
- rev_index = CombinedGraphIndex(rev_indices)
- btree_index.bloom_hits = 0
- drop_cache()
- now = time.time()
- # VersionedFiles can do multi-key extraction, so we can use that.
- index = _KnitGraphIndex(rev_index, lambda:True, deltas=True, parents=True)
- vf = KnitVersionedFiles(index, None)
- graph = Graph(vf)
- search = graph._make_breadth_first_searcher([revid])
- while True:
- try:
- search.next()
- except StopIteration:
- break
- finish = time.time()
- print "%s: search_from_revid in %0.3f, bloom(%d)" % (label, finish - now, btree_index.bloom_hits)
+ if 'revision' in fixtures:
+ rev_names = [name for name in names if name.endswith('.rix')]
+ rev_indices = [index for name, index in iter_indices(rev_names, target, factory)]
+ rev_index = CombinedGraphIndex(rev_indices)
+ # pick the lexograph middle revision, just because.
+ all_revs = sorted(node[1] for node in rev_index.iter_all_entries())
+ revid = all_revs[len(all_revs)/2]
+ # reopen indices
+ rev_indices = [index for name, index in iter_indices(rev_names, target, factory)]
+ rev_index = CombinedGraphIndex(rev_indices)
+ btree_index.bloom_hits = 0
+ drop_cache()
+ now = time.time()
+ # VersionedFiles can do multi-key extraction, so we can use that.
+ index = _KnitGraphIndex(rev_index, lambda:True, deltas=True, parents=True)
+ vf = KnitVersionedFiles(index, None)
+ graph = Graph(vf)
+ search = graph._make_breadth_first_searcher([revid])
+ while True:
+ try:
+ search.next()
+ except StopIteration:
+ break
+ finish = time.time()
+ print "%s: search_from_revid in %0.3f, bloom(%d)" % (label, finish - now, btree_index.bloom_hits)
# pathologic miss-lookups: ask each index of each type for the keys held by the
# others of that type
- btree_index.bloom_hits = 0
- drop_cache()
- now = time.time()
- for name, index in iter_indices(names, target, factory):
- suffix = name[-4:]
- other_keys = set()
- for othername, keys in name_keys.items():
- if othername != name and othername.endswith(suffix):
- other_keys.update(keys)
- for node in index.iter_entries(other_keys):
- pass
- finish = time.time()
- print "%s: miss torture in %0.3f, bloom(%d)" % (label, finish - now, btree_index.bloom_hits)
- print "%s: -------Done---------" % (label,)
+ if 'miss' in fixtures:
+ btree_index.bloom_hits = 0
+ drop_cache()
+ now = time.time()
+ for name, index in iter_indices(names, target, factory):
+ suffix = name[-4:]
+ other_keys = set()
+ for othername, keys in name_keys.items():
+ if othername != name and othername.endswith(suffix):
+ other_keys.update(keys)
+ for node in index.iter_entries(other_keys):
+ pass
+ finish = time.time()
+ print "%s: miss torture in %0.3f, bloom(%d)" % (label, finish - now, btree_index.bloom_hits)
+ print "%s: -------Done---------" % (label,)
class cmd_indexbench(Command):
@@ -145,12 +150,17 @@
Option('graph', help='bench the GraphIndex class'),
Option('btree', help='bench the BTreeGraphIndex class'),
Option('drop-cache', help='drop caches between fixtures'),
+ ListOption('fixture', type=str,
+ help='fixtures to test: one of all, shuffle, text, revision, miss')
]
takes_args = ['sample_repository']
- def run(self, sample_repository, graph=True, btree=True, drop_cache=False):
+ def run(self, sample_repository, graph=True, btree=True, drop_cache=False,
+ fixture=None):
+ if not fixture:
+ fixture = ['all', 'shuffle', 'text', 'revision', 'miss']
source = get_transport(sample_repository)
source = source.clone('.bzr/repository/indices')
names = source.list_dir('.')
@@ -172,17 +182,17 @@
if btree:
self.test_class(names, source, BTreeGraphIndex, BTreeBuilder,
- 'BTreeIndex', name_keys, text_keys, drop_cache)
+ 'BTreeIndex', name_keys, text_keys, drop_cache, fixture)
if graph:
self.test_class(names, source, GraphIndex, GraphIndexBuilder,
- 'GraphIndex', name_keys, text_keys, drop_cache)
+ 'GraphIndex', name_keys, text_keys, drop_cache, fixture)
def test_class(self, names, source, factory, builder, label, name_keys,
- text_keys, drop_cache):
+ text_keys, drop_cache, fixtures):
workingdir = tempfile.mkdtemp()
t = get_transport(workingdir)
try:
time_index(names, source, factory, builder, t, label, name_keys,
- text_keys, drop_cache)
+ text_keys, drop_cache, fixtures)
finally:
t.delete_tree('.')
More information about the bazaar-commits
mailing list