Patchwork [3,of,8] perf: use the new setup function in "perfbookmarks"

login
register
mail settings
Submitter Boris Feld
Date Nov. 21, 2018, 6:33 p.m.
Message ID <73f19cded5865968e672.1542825233@localhost.localdomain>
Download mbox | patch
Permalink /patch/36700/
State Accepted
Headers show

Comments

Boris Feld - Nov. 21, 2018, 6:33 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542669286 0
#      Mon Nov 19 23:14:46 2018 +0000
# Node ID 73f19cded5865968e672a0e1d1b6aaaef2b77e18
# Parent  04a1a32aaaedc6a75117994dbf2823e39204fd7d
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 73f19cded586
perf: use the new setup function in "perfbookmarks"

This command was picked arbitrarily to display the usefulness of the new
feature. In my Mercurial repository (with very few bookmarks), moving cache
cleanup in the dedicated setup function has a visible  and stable effect on
the benchmark number.

before: ! wall 0.000061 comb 0.000000 user 0.000000 sys 0.000000 (median of 40837)
after:  ! wall 0.000058 comb 0.000000 user 0.000000 sys 0.000000 (median of 40500)

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -576,10 +576,12 @@  def perfbookmarks(ui, repo, **opts):
     """benchmark parsing bookmarks from disk to memory"""
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
-    def d():
+
+    def s():
         clearfilecache(repo, b'_bookmarks')
+    def d():
         repo._bookmarks
-    timer(d)
+    timer(d, setup=s)
     fm.end()
 
 @command(b'perfbundleread', formatteropts, b'BUNDLE')