changeset 879:99c42969417f

hggitperf: add a command to measure the perf of saving the foldmap
author Siddharth Agarwal <sid0@fb.com>
date Thu, 09 Apr 2015 20:35:07 -0700
parents be105c4dda7b
children 10e61cd25e67
files contrib/hggitperf.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/hggitperf.py
+++ b/contrib/hggitperf.py
@@ -6,7 +6,7 @@
 '''
 
 from mercurial import cmdutil
-import time, os
+import time, os, tempfile
 import functools
 
 cmdtable = {}
@@ -69,3 +69,15 @@
     timer, fm = gettimer(ui)
     timer(repo.githandler.load_map)
     fm.end()
+
+@command('perfgitsavemap')
+def perfgitsavemap(ui, repo):
+    timer, fm = gettimer(ui)
+    repo.githandler.load_map()
+    fd, f = tempfile.mkstemp(prefix='.git-mapfile-', dir=repo.path)
+    basename = os.path.basename(f)
+    try:
+        timer(lambda: repo.githandler.save_map(basename))
+    finally:
+        os.unlink(f)
+    fm.end()