Download:
child 19:4a77e5b067b8
parent 17:f6be82ed1b09
18:246fe5208556
Anton Shestakov <engored@ya.ru>, Fri, 08 May 2015 15:18:50 +0800
bench: move test() closer to MARKS

1 файлов изменено, 39 вставок(+), 39 удалений(-) [+]
bench.py file | annotate | diff | comparison | revisions
--- a/bench.py Fri May 08 15:18:12 2015 +0800
+++ b/bench.py Fri May 08 15:18:50 2015 +0800
@@ -33,6 +33,45 @@
parser.add_argument('--retry', action='store_true', help='try and reduce existing timings')
+def test(mark, mintime=1.0, mintries=3, dropcache=True):
+ results = []
+
+ cmd = [rel(TESTHGREPO, 'hg'), '-R', TESTREPO]
+
+ if mark == 'blame':
+ cmd += ['blame', rel(TESTREPO, 'README')]
+ elif mark == 'grepall':
+ cmd += ['grep', '--all', 'version', rel(TESTREPO, 'README')]
+ elif mark == 'grepallf':
+ cmd += ['grep', '--all', '--follow', 'version', rel(TESTREPO, 'README')]
+ elif mark == 'stco':
+ cmd += ['status', '--copies', rel(TESTREPO, 'README')]
+ elif mark == 'diff':
+ cmd += ['diff', '-r', 'tip~100:tip', rel(TESTREPO, 'README')]
+ elif mark == 'diffg':
+ cmd += ['diff', '-r', 'tip~100:tip', '--git', rel(TESTREPO, 'README')]
+ elif mark == 'logfile':
+ cmd += ['log', rel(TESTREPO, 'README')]
+ elif mark == 'logfilecp':
+ cmd += ['log', '--copies', rel(TESTREPO, 'README')]
+ elif mark == 'log1':
+ cmd += ['log', '-l1']
+ elif mark == 'log1000':
+ cmd += ['log', '-l1000']
+
+ while sum(results) < mintime or len(results) < mintries:
+ if dropcache:
+ shutil.rmtree(rel(TESTREPO, '.hg', 'cache'), ignore_errors=True)
+ start = time.time()
+ try:
+ subprocess.check_output(cmd)
+ except subprocess.CalledProcessError:
+ return None
+ results.append(time.time() - start)
+
+ return min(results)
+
+
def getnodes(revsets):
cmd = [HG, 'log', '-R', TESTHGREPO, '-T', '{node}\n']
for revset in revsets:
@@ -110,45 +149,6 @@
return todo
-def test(mark, mintime=1.0, mintries=3, dropcache=True):
- results = []
-
- cmd = [rel(TESTHGREPO, 'hg'), '-R', TESTREPO]
-
- if mark == 'blame':
- cmd += ['blame', rel(TESTREPO, 'README')]
- elif mark == 'grepall':
- cmd += ['grep', '--all', 'version', rel(TESTREPO, 'README')]
- elif mark == 'grepallf':
- cmd += ['grep', '--all', '--follow', 'version', rel(TESTREPO, 'README')]
- elif mark == 'stco':
- cmd += ['status', '--copies', rel(TESTREPO, 'README')]
- elif mark == 'diff':
- cmd += ['diff', '-r', 'tip~100:tip', rel(TESTREPO, 'README')]
- elif mark == 'diffg':
- cmd += ['diff', '-r', 'tip~100:tip', '--git', rel(TESTREPO, 'README')]
- elif mark == 'logfile':
- cmd += ['log', rel(TESTREPO, 'README')]
- elif mark == 'logfilecp':
- cmd += ['log', '--copies', rel(TESTREPO, 'README')]
- elif mark == 'log1':
- cmd += ['log', '-l1']
- elif mark == 'log1000':
- cmd += ['log', '-l1000']
-
- while sum(results) < mintime or len(results) < mintries:
- if dropcache:
- shutil.rmtree(rel(TESTREPO, '.hg', 'cache'), ignore_errors=True)
- start = time.time()
- try:
- subprocess.check_output(cmd)
- except subprocess.CalledProcessError:
- return None
- results.append(time.time() - start)
-
- return min(results)
-
-
def makeclean():
subprocess.check_output(['make', '--directory', TESTHGREPO, 'clean'], stderr=subprocess.STDOUT)