Commit 03bf5afc authored by Mathieu Giraud's avatar Mathieu Giraud

benchmark-releases.py: exit with 42 when the last release/HEAD has significant...

benchmark-releases.py: exit with 42 when the last release/HEAD has significant difference with the previous one
parent c8c3a1fc
...@@ -220,6 +220,7 @@ def run_all(tag, args, retries): ...@@ -220,6 +220,7 @@ def run_all(tag, args, retries):
def bench_line(f, release, stats, index, format='%8.2f', previous_release=None, colorize=True): def bench_line(f, release, stats, index, format='%8.2f', previous_release=None, colorize=True):
f.write('%-9s' % release) f.write('%-9s' % release)
warned = False
for tag in BENCHS: for tag in BENCHS:
if (tag,release) in stats: if (tag,release) in stats:
if stats[tag, release] is not None: if stats[tag, release] is not None:
...@@ -232,16 +233,19 @@ def bench_line(f, release, stats, index, format='%8.2f', previous_release=None, ...@@ -232,16 +233,19 @@ def bench_line(f, release, stats, index, format='%8.2f', previous_release=None,
previous_val = stats[tag,previous_release][index] previous_val = stats[tag,previous_release][index]
if val/previous_val >= 1 + WARN_RATIO: if val/previous_val >= 1 + WARN_RATIO:
b = color(ANSI.RED, b) if colorize else '!' + b[1:] b = color(ANSI.RED, b) if colorize else '!' + b[1:]
warned = True
elif val/previous_val <= 1 - WARN_RATIO: elif val/previous_val <= 1 - WARN_RATIO:
b = color(ANSI.GREEN, b) if colorize else '!' + b[1:] b = color(ANSI.GREEN, b) if colorize else '!' + b[1:]
warned = True
else: else:
b = '%8s' % 'x' b = '%8s' % 'x'
else: else:
b = '%8s' % '-' b = '%8s' % '-'
f.write(b) f.write(b)
f.write('\n') f.write('\n')
return warned
def show_benchs(f, colorize): def show_benchs(f, watched_release=None, colorize=True):
f.write('\n') f.write('\n')
f.write(color(ANSI.YELLOW, '\nBenchmark summary, %s\n' % datetime.datetime.now().isoformat(), colorize)) f.write(color(ANSI.YELLOW, '\nBenchmark summary, %s\n' % datetime.datetime.now().isoformat(), colorize))
for tag, bench in BENCHS.items(): for tag, bench in BENCHS.items():
...@@ -252,6 +256,8 @@ def show_benchs(f, colorize): ...@@ -252,6 +256,8 @@ def show_benchs(f, colorize):
for tag in BENCHS: for tag in BENCHS:
f.write('%8s' % tag) f.write('%8s' % tag)
warned = False
for (key, index, format) in [ for (key, index, format) in [
('Time (s)', 0, '%8.2f'), ('Time (s)', 0, '%8.2f'),
('Memory (MB)', 1, '%8d'), ('Memory (MB)', 1, '%8d'),
...@@ -259,9 +265,12 @@ def show_benchs(f, colorize): ...@@ -259,9 +265,12 @@ def show_benchs(f, colorize):
f.write(color(ANSI.YELLOW, '\n%s\n' % key, colorize)) f.write(color(ANSI.YELLOW, '\n%s\n' % key, colorize))
previous_release = None previous_release = None
for release in installed(): for release in installed():
bench_line(f, release, stats, index, format, previous_release, colorize) w = bench_line(f, release, stats, index, format, previous_release, colorize)
previous_release = release previous_release = release
if w and release == watched_release:
warned = True
return warned
def bench_all(retries, selected_benchs): def bench_all(retries, selected_benchs):
try: try:
...@@ -294,4 +303,7 @@ if __name__ == '__main__': ...@@ -294,4 +303,7 @@ if __name__ == '__main__':
bench_all(args.retries, args.benchs) bench_all(args.retries, args.benchs)
show_benchs(sys.stdout, colorize=True) show_benchs(sys.stdout, colorize=True)
print('\n==>', OUT) print('\n==>', OUT)
show_benchs(open(OUT, 'w'), colorize=False)
watched_release = installed()[-1]
warned = show_benchs(open(OUT, 'w'), watched_release=watched_release, colorize=False)
sys.exit(42 if warned else 0)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment