Patchwork [3,of,6] perftemplating: drop usage of buffer

login
register
mail settings
Submitter Boris Feld
Date June 11, 2018, 7:52 a.m.
Message ID <5966c21ead803fb7bf57.1528703542@localhost.localdomain>
Download mbox | patch
Permalink /patch/32052/
State Accepted
Headers show

Comments

Boris Feld - June 11, 2018, 7:52 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527784995 -7200
#      Thu May 31 18:43:15 2018 +0200
# Node ID 5966c21ead803fb7bf57194b8c8d9714860f00a1
# Parent  1f377f7bfc6c960d8f45bc0c85f22f15e89514e6
# EXP-Topic perftemplate
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 5966c21ead80
perftemplating: drop usage of buffer

The buffer can consume a lot of memory and change various internal behaviors.
Writing to dev/null seems more appropriate when it comes to benchmark.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -899,15 +899,17 @@  def perfmoonwalk(ui, repo, **opts):
 
 @command('perftemplating', formatteropts)
 def perftemplating(ui, repo, *revs, **opts):
+    nullui = ui.copy()
+    nullui.fout = open(os.devnull, 'wb')
+    nullui.disablepager()
+
     def format():
-        commands.log(ui, repo, rev=revs, date='', user='',
+        commands.log(nullui, repo, rev=revs, date='', user='',
                      template='{date|shortdate} [{rev}:{node|short}]'
                               ' {author|person}: {desc|firstline}\n')
 
     timer, fm = gettimer(ui, opts)
-    ui.pushbuffer()
     timer(format)
-    ui.popbuffer()
     fm.end()
 
 @command('perfcca', formatteropts)