perf: add a --stats argument to perfhelper-pathcopies
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 17 Sep 2019 18:36:30 +0200
changeset 42942 adac17faa72e
parent 42941 3a1ad3aeb64a
child 42943 5fadf6103790
perf: add a --stats argument to perfhelper-pathcopies The arguments will display some statisting about the distribution of the value we measure.
contrib/perf.py
--- a/contrib/perf.py	Tue Sep 17 09:49:30 2019 +0200
+++ b/contrib/perf.py	Tue Sep 17 18:36:30 2019 +0200
@@ -1745,6 +1745,7 @@
          [
           (b'r', b'revs', [], b'restrict search to these revisions'),
           (b'', b'timing', False, b'provides extra data (costly)'),
+          (b'', b'stats', False, b'provides statistic about the measured data'),
          ])
 def perfhelperpathcopies(ui, repo, revs=[], **opts):
     """find statistic about potential parameters for the `perftracecopies`
@@ -1763,6 +1764,7 @@
     opts = _byteskwargs(opts)
     fm = ui.formatter(b'perf', opts)
     dotiming = opts[b'timing']
+    dostats = opts[b'stats']
 
     if dotiming:
         header = '%12s %12s %12s %12s %12s %12s\n'
@@ -1782,6 +1784,16 @@
         revs = ['all()']
     revs = scmutil.revrange(repo, revs)
 
+
+    if dostats:
+        alldata = {
+            'nbrevs': [],
+            'nbmissingfiles': [],
+        }
+        if dotiming:
+            alldata['nbrenames'] = []
+            alldata['time'] = []
+
     roi = repo.revs('merge() and %ld', revs)
     for r in roi:
         ctx = repo[r]
@@ -1801,6 +1813,16 @@
                     b'nbrevs': len(repo.revs('%d::%d', b, p)),
                     b'nbmissingfiles': len(missing),
                 }
+                alldata['nbrevs'].append((
+                    data['nbrevs'],
+                    base.hex(),
+                    parent.hex(),
+                ))
+                alldata['nbmissingfiles'].append((
+                    data['nbmissingfiles'],
+                    base.hex(),
+                    parent.hex(),
+                ))
                 if dotiming:
                     begin = util.timer()
                     renames = copies.pathcopies(base, parent)
@@ -1808,6 +1830,16 @@
                     # not very stable timing since we did only one run
                     data['time'] = end - begin
                     data['nbrenamedfiles'] = len(renames)
+                    alldata['time'].append((
+                        data['time'],
+                        base.hex(),
+                        parent.hex(),
+                    ))
+                    alldata['nbrenames'].append((
+                        data['nbrenamedfiles'],
+                        base.hex(),
+                        parent.hex(),
+                    ))
                 fm.startitem()
                 fm.data(**data)
                 out = data.copy()
@@ -1816,6 +1848,19 @@
                 fm.plain(output % out)
 
     fm.end()
+    if dostats:
+        # use a second formatter because the data are quite different, not sure
+        # how it flies with the templater.
+        fm = ui.formatter(b'perf', opts)
+        entries = [
+            ('nbrevs', 'number of revision covered'),
+            ('nbmissingfiles', 'number of missing files at head'),
+        ]
+        if dotiming:
+            entries.append(('nbrenames',
+                            'renamed files'))
+            entries.append(('time', 'time'))
+        _displaystats(ui, opts, entries, alldata)
 
 @command(b'perfcca', formatteropts)
 def perfcca(ui, repo, **opts):