Rev 23: Update the test suite to take a branch, so we know that we are iterating a reasonable amount of history in http://bzr.arbash-meinel.com/plugins/index2

John Arbash Meinel john at arbash-meinel.com
Wed Jul 2 18:57:39 BST 2008


At http://bzr.arbash-meinel.com/plugins/index2

------------------------------------------------------------
revno: 23
revision-id: john at arbash-meinel.com-20080702174605-j9oaswfan8zvg2k7
parent: john at arbash-meinel.com-20080702172707-906pywtz35vgv99f
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: index2
timestamp: Wed 2008-07-02 12:46:05 -0500
message:
  Update the test suite to take a branch, so we know that we are iterating a reasonable amount of history
-------------- next part --------------
=== modified file 'indexbench.py'
--- a/indexbench.py	2008-07-02 17:27:07 +0000
+++ b/indexbench.py	2008-07-02 17:46:05 +0000
@@ -53,7 +53,7 @@
 
 
 def time_index(names, source, factory, builder, target, label, name_keys,
-    text_keys, use_drop_cache, fixtures, lsprof):
+    text_keys, use_drop_cache, fixtures, lsprof, tip_revision_id):
     if use_drop_cache:
         drop_cache = drop_caches
     else:
@@ -118,11 +118,6 @@
 # follow a revision graph
     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)
@@ -133,7 +128,7 @@
         index = _KnitGraphIndex(rev_index, lambda:True, deltas=True, parents=True)
         vf = KnitVersionedFiles(index, None)
         graph = Graph(vf)
-        search = graph._make_breadth_first_searcher([revid])
+        search = graph._make_breadth_first_searcher([(tip_revision_id,)])
         while True:
             try:
                 search.next()
@@ -177,14 +172,17 @@
         ]
 
 
-    takes_args = ['sample_repository']
+    takes_args = ['sample_branch']
 
-    def run(self, sample_repository, graph=True, btree=True, drop_cache=False,
-        fixture=None,lspro=False):
+    def run(self, sample_branch, graph=True, btree=True, drop_cache=False,
+            fixture=None, lspro=False):
         if not fixture:
             fixture = ['all', 'shuffle', 'text', 'revision', 'miss']
-        source = get_transport(sample_repository)
-        source = source.clone('.bzr/repository/indices')
+        from bzrlib.branch import Branch
+        source_branch = Branch.open(sample_branch)
+        source = source_branch.repository._transport
+        source = source.clone('indices')
+        tip_revision_id = source_branch.last_revision()
         names = source.list_dir('.')
         name_keys = {}
         text_keys = set()
@@ -204,17 +202,19 @@
 
         if btree:
             self.test_class(names, source, BTreeGraphIndex, BTreeBuilder,
-                'BTreeIndex', name_keys, text_keys, drop_cache, fixture, lspro)
+                'BTreeIndex', name_keys, text_keys, drop_cache, fixture, lspro,
+                tip_revision_id)
         if graph:
             self.test_class(names, source, GraphIndex, GraphIndexBuilder,
-                'GraphIndex', name_keys, text_keys, drop_cache, fixture, lspro)
+                'GraphIndex', name_keys, text_keys, drop_cache, fixture, lspro,
+                tip_revision_id)
 
     def test_class(self, names, source, factory, builder, label, name_keys,
-        text_keys, drop_cache, fixtures, lsprof):
+        text_keys, drop_cache, fixtures, lsprof, tip_revision_id):
         workingdir = tempfile.mkdtemp()
         t = get_transport(workingdir)
         try:
             time_index(names, source, factory, builder, t, label, name_keys,
-                text_keys, drop_cache, fixtures, lsprof)
+                text_keys, drop_cache, fixtures, lsprof, tip_revision_id)
         finally:
             t.delete_tree('.')



More information about the bazaar-commits mailing list