Rev 1: A very trivial plugin to time 'iter_changes' results. in http://bzr.arbash-meinel.com/plugins/time_iter_changes

John Arbash Meinel john at arbash-meinel.com
Wed Oct 21 19:21:57 BST 2009


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

------------------------------------------------------------
revno: 1
revision-id: john at arbash-meinel.com-20091021182139-jbwv6gbucf1g89vu
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: time_iter_changes
timestamp: Wed 2009-10-21 13:21:39 -0500
message:
  A very trivial plugin to time 'iter_changes' results.
-------------- next part --------------
=== added file '__init__.py'
--- a/__init__.py	1970-01-01 00:00:00 +0000
+++ b/__init__.py	2009-10-21 18:21:39 +0000
@@ -0,0 +1,36 @@
+# Copyright (C) 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import time
+from bzrlib import commands
+
+
+class cmd_time_iter_changes(commands.Command):
+    """Run 'tree.iter_changes(tree.basis_tree())' and report the timing."""
+
+    def run(self):
+        from bzrlib import workingtree
+        tree = workingtree.WorkingTree.open_containing('.')[0]
+        tree.lock_read()
+        try:
+            t = time.time()
+            changes = list(tree.iter_changes(tree.basis_tree()))
+            delta = time.time() - t
+        finally:
+            tree.unlock()
+            self.outf.write('%d changes in %.3fs\n' % (len(changes), delta))
+
+commands.register_command(cmd_time_iter_changes)



More information about the bazaar-commits mailing list