Download:
child 17:f6be82ed1b09
parent 15:e644175a79bb
16:7adaad90a5d1
Anton Shestakov <engored@ya.ru>, Thu, 07 May 2015 13:23:14 +0800
bench: --auto for trying to guess revisions (new or spikes)

1 файлов изменено, 80 вставок(+), 4 удалений(-) [+]
bench.py file | annotate | diff | comparison | revisions
--- a/bench.py Thu May 07 13:21:40 2015 +0800
+++ b/bench.py Thu May 07 13:23:14 2015 +0800
@@ -25,7 +25,9 @@
parser = ArgumentParser(description='Benchmark revisions and put results in the db.')
-parser.add_argument('revsets', metavar='REVSET', default=('last(all(), 120)',), nargs='*', help='update these revisions')
+group = parser.add_mutually_exclusive_group()
+group.add_argument('revsets', metavar='REVSET', default=('last(all(), 120)',), nargs='*', help='update these revisions')
+group.add_argument('--auto', metavar='MAXREVS', type=int, help='guess revisions, up to MAXREVS')
parser.add_argument('--retry', action='store_true', help='try and reduce existing timings')
@@ -37,6 +39,75 @@
return output.split()
+def guessnew(maxrevs):
+ """ Pick one continuous span of nodes that still need testing. """
+ cmd = [HG, 'log', '-R', TESTHGREPO, '-T', '{node}\n', '-r', 'sort(all(), rev)']
+ output = subprocess.check_output(cmd)
+ nodes = output.split()
+ picking = False
+ todo = []
+ conn = sqlite3.connect(DBPATH)
+ while len(todo) < maxrevs:
+ node = nodes.pop()
+ count = conn.execute('SELECT COUNT(*) FROM results WHERE node = ?', (node,)).fetchone()[0]
+ if count < len(MARKS) * len(('without cache', 'with cache')):
+ todo.append(node)
+ picking = True
+ elif picking:
+ break
+ conn.close()
+ return todo
+
+
+def guessspikes(maxrevs):
+ cmd = [HG, 'log', '-R', TESTHGREPO, '-T', '{node}\n', '-r', 'sort(all(), -rev)']
+ output = subprocess.check_output(cmd)
+ nodes = output.split()
+ todo = []
+ conn = sqlite3.connect(DBPATH)
+ limits = {
+ mark:
+ conn.execute(
+ 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ (mark, False)).fetchone()
+ +
+ conn.execute(
+ 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ (mark, True)).fetchone()
+ for mark in MARKS
+ }
+ results = {}
+ for node in nodes:
+ resultsq = conn.execute(
+ 'SELECT mark, time, cache FROM results WHERE node = ?',
+ (node,))
+ for mark, t, cache in resultsq:
+ results.setdefault(node, {}).setdefault(mark, [None, None])
+ if not cache:
+ results[node][mark][0] = t
+ else:
+ results[node][mark][1] = t
+ conn.close()
+ for i in range(1, len(nodes) - 1):
+ if len(todo) >= maxrevs:
+ break
+ node1 = nodes[i - 1]
+ node2 = nodes[i]
+ node3 = nodes[i + 1]
+ for mark in MARKS:
+ for cache in (False, True):
+ try:
+ eps = abs(results[node1][mark][cache] - results[node3][mark][cache])
+ delta = results[node2][mark][cache] - results[node1][mark][cache]
+ l = limits[mark][2:4] if cache else limits[mark][0:2]
+ if delta > eps * 10 and delta > (l[1] - l[0]) * 0.1:
+ if node2 not in todo:
+ todo.append(node2)
+ except (KeyError, TypeError):
+ continue
+ return todo
+
+
def test(mark, mintime=1.0, mintries=3, dropcache=True):
results = []
@@ -156,11 +227,16 @@
os.remove(LOCKFILE)
-def main(revsets, retry=False):
+def main(args):
lock()
try:
dbinit()
- dbupdate(revsets, retry)
+ if args.auto:
+ if args.retry:
+ args.revsets = guessspikes(args.auto)
+ else:
+ args.revsets = guessnew(args.auto)
+ dbupdate(args.revsets, args.retry)
finally:
unlock()
@@ -168,4 +244,4 @@
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
args = parser.parse_args()
- main(args.revsets, args.retry)
+ main(args)