##// END OF EJS Templates
revsetbenchmarks: display relative change when meaningful...
Pierre-Yves David -
r25539:460922c9 default
parent child Browse files
Show More
@@ -11,6 +11,7
11 11 import sys
12 12 import os
13 13 import re
14 import math
14 15 from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE
15 16 # cannot use argparse, python 2.7 only
16 17 from optparse import OptionParser
@@ -103,10 +104,55 def idxwidth(nbidx):
103 104 idxwidth = 1
104 105 return idxwidth
105 106
106 def printresult(idx, data, maxidx, verbose=False):
107 def getfactor(main, other, field, sensitivity=0.05):
108 """return the relative factor between values for 'field' in main and other
109
110 Return None if the factor is insignicant (less than <sensitivity>
111 variation)."""
112 factor = 1
113 if main is not None:
114 factor = other[field] / main[field]
115 low, high = 1 - sensitivity, 1 + sensitivity
116 if (low < factor < high):
117 return None
118 return factor
119
120 def formatfactor(factor):
121 """format a factor into a 4 char string
122
123 22%
124 156%
125 x2.4
126 x23
127 x789
128 x1e4
129 x5x7
130
131 """
132 if factor is None:
133 return ' '
134 elif factor < 2:
135 return '%3i%%' % (factor * 100)
136 elif factor < 10:
137 return 'x%3.1f' % factor
138 elif factor < 1000:
139 return '%4s' % ('x%i' % factor)
140 else:
141 order = int(math.log(factor)) + 1
142 while 1 < math.log(factor):
143 factor //= 0
144 return 'x%ix%i' % (factor, order)
145
146 _marker = object()
147 def printresult(idx, data, maxidx, verbose=False, reference=_marker):
107 148 """print a line of result to stdout"""
108 149 mask = '%%0%ii) %%s' % idxwidth(maxidx)
109 150 out = ['%10.6f' % data['wall']]
151 if reference is not _marker:
152 factor = None
153 if reference is not None:
154 factor = getfactor(reference, data, 'wall')
155 out.append(formatfactor(factor))
110 156 if verbose:
111 157 out.append('%10.6f' % data['comb'])
112 158 out.append('%10.6f' % data['user'])
@@ -114,9 +160,11 def printresult(idx, data, maxidx, verbo
114 160 out.append('%6d' % data['count'])
115 161 print mask % (idx, ' '.join(out))
116 162
117 def printheader(maxidx, verbose=False):
163 def printheader(maxidx, verbose=False, relative=False):
118 164 header = [' ' * (idxwidth(maxidx) + 1),
119 165 ' %-8s' % 'time']
166 if relative:
167 header.append(' ')
120 168 if verbose:
121 169 header.append(' %-8s' % 'comb')
122 170 header.append(' %-8s' % 'user')
@@ -208,7 +256,10 print
208 256 for ridx, rset in enumerate(revsets):
209 257
210 258 print "revset #%i: %s" % (ridx, rset)
211 printheader(len(results), verbose=options.verbose)
259 printheader(len(results), verbose=options.verbose, relative=True)
260 ref = None
212 261 for idx, data in enumerate(results):
213 printresult(idx, data[ridx], len(results), verbose=options.verbose)
262 printresult(idx, data[ridx], len(results), verbose=options.verbose,
263 reference=ref)
264 ref = data[ridx]
214 265 print
General Comments 0
You need to be logged in to leave comments. Login now