Rev 2486: Add benchmarks for loading a knit index with a lot of records. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex

John Arbash Meinel john at arbash-meinel.com
Wed May 9 16:12:36 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex

------------------------------------------------------------
revno: 2486
revision-id: john at arbash-meinel.com-20070509151224-20uys53nsfunfv5k
parent: john at arbash-meinel.com-20070509144042-9uyruriejyp98751
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: knit_index_pyrex
timestamp: Wed 2007-05-09 10:12:24 -0500
message:
  Add benchmarks for loading a knit index with a lot of records.
  Because of (deterministic) variations, the benchmarks are run 2 times.
  For some reason, the second run of a benchmark is approx 40ms faster,
  and the 3rd run is slow again.
added:
  bzrlib/benchmarks/bench_knit.py bench_knit.py-20070509145850-pan5jnd3hl7mfdya-1
modified:
  bzrlib/benchmarks/__init__.py  __init__.py-20060516064526-eb0d37c78e86065d
-------------- next part --------------
=== added file 'bzrlib/benchmarks/bench_knit.py'
--- a/bzrlib/benchmarks/bench_knit.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/benchmarks/bench_knit.py	2007-05-09 15:12:24 +0000
@@ -0,0 +1,90 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Benchmarks for Knit performance"""
+
+import os
+
+from bzrlib import (
+    generate_ids,
+    knit,
+    tests,
+    )
+from bzrlib.benchmarks import Benchmark
+from bzrlib.tests.test_knit import CompiledKnitFeature
+
+
+class BenchKnitIndex(Benchmark):
+    """Benchmark Knit index performance."""
+
+    def create_10k_index(self):
+        """Create an knit index file with 10,000 entries.
+
+        This isn't super realistic, but it *is* big :)
+
+        The file 'test.kndx' will be created.
+        """
+        rev_id = generate_ids.gen_revision_id('long.name at this.example.com')
+        versions = [(rev_id, ('fulltext',), 0, 200, [])]
+        pos = 200
+        for i in xrange(9999):
+            parent_ids = [rev_id]
+            rev_id = generate_ids.gen_revision_id('long.name at this.example.com')
+            versions.append((rev_id, ('line-delta',), pos, 200, parent_ids))
+            pos += 200
+        t = self.get_transport()
+        kndx = knit._KnitIndex(t, 'test.kndx', 'w', create=True,
+                               delay_create=True)
+        kndx.add_versions(versions)
+
+    def setup_load_data_c(self):
+        self.requireFeature(CompiledKnitFeature)
+        orig = knit._load_data
+        def reset():
+            knit._load_data = orig
+        self.addCleanup(reset)
+        knit._load_data = knit._load_data_c
+
+    def setup_load_data_py(self):
+        orig = knit._load_data
+        def reset():
+            knit._load_data = orig
+        self.addCleanup(reset)
+        knit._load_data = knit._load_data_py
+
+    def test_read_10k_index_c(self):
+        self.create_10k_index()
+        self.setup_load_data_c()
+        t = self.get_transport()
+        kndx = self.time(knit._KnitIndex, t, 'test.kndx', 'r')
+
+    def test_read_10k_index_c_again(self):
+        self.create_10k_index()
+        self.setup_load_data_c()
+        t = self.get_transport()
+        kndx = self.time(knit._KnitIndex, t, 'test.kndx', 'r')
+
+    def test_read_10k_index_py(self):
+        self.create_10k_index()
+        self.setup_load_data_py()
+        t = self.get_transport()
+        kndx = self.time(knit._KnitIndex, t, 'test.kndx', 'r')
+
+    def test_read_10k_index_py_again(self):
+        self.create_10k_index()
+        self.setup_load_data_py()
+        t = self.get_transport()
+        kndx = self.time(knit._KnitIndex, t, 'test.kndx', 'r')

=== modified file 'bzrlib/benchmarks/__init__.py'
--- a/bzrlib/benchmarks/__init__.py	2006-10-16 01:25:46 +0000
+++ b/bzrlib/benchmarks/__init__.py	2007-05-09 15:12:24 +0000
@@ -179,6 +179,7 @@
                    'bzrlib.benchmarks.bench_commit',
                    'bzrlib.benchmarks.bench_info',
                    'bzrlib.benchmarks.bench_inventory',
+                   'bzrlib.benchmarks.bench_knit',
                    'bzrlib.benchmarks.bench_log',
                    'bzrlib.benchmarks.bench_osutils',
                    'bzrlib.benchmarks.bench_rocks',



More information about the bazaar-commits mailing list