Skip to content

Commit bb25314

Browse files
committed
Better format report summary when there is no base set to compare with
1 parent a680b7d commit bb25314

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

corpus_test/generate_report.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ def report(results_dir: str, minifier_ref: str, minifier_sha: str, base_ref: str
350350
:param base_sha: The git sha of the base version of python-minifier we are comparing against
351351
"""
352352

353-
yield f'''
354-
# Python Minifier Test Report
353+
yield f'''# Python Minifier Test Report
355354
356355
Git Ref: {minifier_ref}
357356
Git Sha: {minifier_sha}
@@ -375,24 +374,36 @@ def report(results_dir: str, minifier_ref: str, minifier_sha: str, base_ref: str
375374
try:
376375
base_summary = result_summary(results_dir, python_version, base_sha)
377376
except FileNotFoundError:
378-
base_summary = ResultSet(python_version, base_ref)
379-
380-
mean_time_change = summary.mean_time - base_summary.mean_time
381-
382-
yield (
383-
f'| {python_version} ' +
384-
f'| {summary.valid_count} ' +
385-
f'| {summary.mean_time:.3f} ({mean_time_change:+.3f}) ' +
386-
f'| {format_size_change_detail(summary, base_summary)} ' +
387-
f'| {format_difference(summary.larger_than_original(), base_summary.larger_than_original())} ' +
388-
f'| {format_difference(summary.recursion_error(), base_summary.recursion_error())} ' +
389-
f'| {format_difference(summary.unstable_minification(), base_summary.unstable_minification())} ' +
390-
f'| {format_difference(summary.exception(), base_summary.exception())} |'
391-
)
377+
base_summary = None
378+
379+
if base_summary is None:
380+
yield (
381+
f'| {python_version} ' +
382+
f'| {summary.valid_count} ' +
383+
f'| {summary.mean_time:.3f} ' +
384+
f'| {summary.mean_percent_of_original:.3f}% ' +
385+
f'| {len(list(summary.larger_than_original()))} ' +
386+
f'| {len(list(summary.recursion_error()))} ' +
387+
f'| {len(list(summary.unstable_minification()))} ' +
388+
f'| {len(list(summary.exception()))} |'
389+
)
390+
else:
391+
mean_time_change = summary.mean_time - base_summary.mean_time
392+
393+
yield (
394+
f'| {python_version} ' +
395+
f'| {summary.valid_count} ' +
396+
f'| {summary.mean_time:.3f} ({mean_time_change:+.3f}) ' +
397+
f'| {format_size_change_detail(summary, base_summary)} ' +
398+
f'| {format_difference(summary.larger_than_original(), base_summary.larger_than_original())} ' +
399+
f'| {format_difference(summary.recursion_error(), base_summary.recursion_error())} ' +
400+
f'| {format_difference(summary.unstable_minification(), base_summary.unstable_minification())} ' +
401+
f'| {format_difference(summary.exception(), base_summary.exception())} |'
402+
)
392403

393404
if ENHANCED_REPORT:
394405
yield from report_larger_than_original(results_dir, ['3.14'], minifier_sha)
395-
yield from report_larger_than_base(results_dir, ['3.14'], minifier_sha, base_sha)
406+
yield from report_larger_than_base(results_dir, ['3.13'], minifier_sha, base_sha)
396407
yield from report_slowest(results_dir, ['3.14'], minifier_sha)
397408
yield from report_unstable(results_dir, ['2.7', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'], minifier_sha)
398409
yield from report_exceptions(results_dir, ['2.7', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'], minifier_sha)

0 commit comments

Comments
 (0)