Patchwork [2,of,6] perf: add a command to test performance of membership in ancestor set

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 14, 2012, 7:35 p.m.
Message ID <35eb8d05863f3907b5bf.1355513752@sid0x220>
Download mbox | patch
Permalink /patch/107/
State Accepted
Commit 486bfb200b3f7abf68148a78299c37e12460459c
Headers show

Comments

Siddharth Agarwal - Dec. 14, 2012, 7:35 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1355509398 28800
# Node ID 35eb8d05863f3907b5bfd5f023a4746f91ef97d8
# Parent  dfe0c803b74992f10f41a156ea49bed2a61221ee
perf: add a command to test performance of membership in ancestor set

The new command, perfancestorset, takes an argument denoting which revset to
test the membership of.

Currently this runs through all the ancestors and converts them into a set.
The primary purpose of having this is to compare this approach, currently used
in several places, against the upcoming lazy approach.

Patch

diff -r dfe0c803b749 -r 35eb8d05863f contrib/perf.py
--- a/contrib/perf.py	Tue Dec 11 14:47:33 2012 -0800
+++ b/contrib/perf.py	Fri Dec 14 10:23:18 2012 -0800
@@ -78,6 +78,15 @@ 
             pass
     timer(d)
 
+def perfancestorset(ui, repo, revset):
+    revs = repo.revs(revset)
+    heads = repo.changelog.headrevs()
+    def d():
+        s = set(repo.changelog.ancestors(heads))
+        for rev in revs:
+            rev in s
+    timer(d)
+
 def perfdirstate(ui, repo):
     "a" in repo.dirstate
     def d():
@@ -253,6 +262,7 @@ 
     'perfheads': (perfheads, []),
     'perftags': (perftags, []),
     'perfancestors': (perfancestors, []),
+    'perfancestorset': (perfancestorset, [], "REVSET"),
     'perfdirstate': (perfdirstate, []),
     'perfdirstatedirs': (perfdirstate, []),
     'perfdirstatewrite': (perfdirstatewrite, []),