--- a/bench.py Thu May 07 13:21:40 2015 +0800
+++ b/bench.py Thu May 07 13:23:14 2015 +0800
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')
+ """ 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)
+ conn = sqlite3.connect(DBPATH)
+ while len(todo) < maxrevs:
+ count = conn.execute('SELECT COUNT(*) FROM results WHERE node = ?', (node,)).fetchone()[0]
+ if count < len(MARKS) * len(('without cache', 'with cache')):
+def guessspikes(maxrevs):
+ cmd = [HG, 'log', '-R', TESTHGREPO, '-T', '{node}\n', '-r', 'sort(all(), -rev)']
+ output = subprocess.check_output(cmd)
+ conn = sqlite3.connect(DBPATH)
+ 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ (mark, False)).fetchone()
+ 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ (mark, True)).fetchone()
+ resultsq = conn.execute(
+ 'SELECT mark, time, cache FROM results WHERE node = ?',
+ for mark, t, cache in resultsq:
+ results.setdefault(node, {}).setdefault(mark, [None, None])
+ results[node][mark][0] = t
+ results[node][mark][1] = t
+ for i in range(1, len(nodes) - 1):
+ if len(todo) >= maxrevs:
+ for cache in (False, True):
+ 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:
+ except (KeyError, TypeError):
def test(mark, mintime=1.0, mintries=3, dropcache=True):
-def main(revsets, retry=False):
- dbupdate(revsets, retry)
+ args.revsets = guessspikes(args.auto)
+ args.revsets = guessnew(args.auto)
+ dbupdate(args.revsets, args.retry)
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
args = parser.parse_args()
- main(args.revsets, args.retry)