Skip to content

Commit

Permalink
Slightly adjust comment format, fix detail table formatting. (#2658)
Browse files Browse the repository at this point in the history
* Slightly adjust comment format, fix detail table formatting.

* Always add a conclusion.
  • Loading branch information
futursolo committed May 4, 2022
1 parent 983293d commit fd1906f
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions ci/make_example_size_cmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import json


header = "| examples | master (KB) | pull request (KB) | diff |"
sep = "| --- | --- | --- | --- | "
header = "| examples | master (KB) | pull request (KB) | diff (KB) | diff (%) |"
sep = "| --- | --- | --- | --- | --- |"


def format_size(size: Optional[int]) -> str:
Expand All @@ -20,18 +20,18 @@ def format_size(size: Optional[int]) -> str:

def format_diff_size(
master_size: Optional[int], pr_size: Optional[int]
) -> Tuple[str, bool]:
) -> Tuple[str, str, bool]:
if master_size is None or pr_size is None:
return ("N/A", False)
return ("N/A", "N/A", False)

diff = pr_size - master_size

if diff == 0:
return ("0", False)
return ("0", "0.000%", False)

diff_percent = diff / master_size

return (f"{diff / 1024:+.3f}({diff_percent:+.3%})", abs(diff_percent) > 0.01)
return (f"{diff / 1024:+.3f}", f"{diff_percent:+.3%}", abs(diff_percent) >= 0.01)


def main() -> None:
Expand All @@ -47,6 +47,7 @@ def main() -> None:
lines.append("### Size Comparison")
lines.append("")
lines.append("<details>")
lines.append("")
lines.append(header)
lines.append(sep)

Expand All @@ -56,9 +57,14 @@ def main() -> None:
master_size_str = format_size(master_size)
pr_size_str = format_size(pr_size)

(diff_str, diff_significant) = format_diff_size(master_size, pr_size)
(diff_str, diff_percent, diff_significant) = format_diff_size(
master_size, pr_size
)

line_str = f"| {i} | {master_size_str} | {pr_size_str} | {diff_str} |"
line_str = (
f"| {i} | {master_size_str} | {pr_size_str} | "
f"{diff_str} | {diff_percent} |"
)

lines.append(line_str)

Expand All @@ -67,16 +73,25 @@ def main() -> None:

lines.append("")
lines.append("</details>")
lines.append("")

if significant_lines:
lines.append("")
lines.append("⚠️ The following examples have changed their size significantly:")

if len(significant_lines) == 1:
lines.append("⚠️ The following example has changed its size significantly:")
else:
lines.append(
"⚠️ The following examples have changed their size significantly:"
)
lines.append("")

lines.append(header)
lines.append(sep)
lines.extend(significant_lines)

else:
lines.append("✅ None of the examples has changed their size significantly.")

output = "\n".join(lines)

with open(os.environ["GITHUB_ENV"], "a+") as f:
Expand Down

1 comment on commit fd1906f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yew master branch benchmarks (Lower is better)

Benchmark suite Current: fd1906f Previous: 983293d Ratio
yew-struct-keyed 01_run1k 158.5575 212.3465 0.75
yew-struct-keyed 02_replace1k 170.13049999999998 230.697 0.74
yew-struct-keyed 03_update10th1k_x16 278.2025 398.56 0.70
yew-struct-keyed 04_select1k 50.2155 73.971 0.68
yew-struct-keyed 05_swap1k 69.78200000000001 105.5495 0.66
yew-struct-keyed 06_remove-one-1k 25.3115 33.6595 0.75
yew-struct-keyed 07_create10k 2653.8785 3239.5725 0.82
yew-struct-keyed 08_create1k-after1k_x2 365.9105 477.6115 0.77
yew-struct-keyed 09_clear1k_x8 147.3945 207.303 0.71
yew-struct-keyed 21_ready-memory 1.457233428955078 1.457233428955078 1
yew-struct-keyed 22_run-memory 1.6938209533691406 1.6594467163085938 1.02
yew-struct-keyed 23_update5-memory 1.6972122192382812 1.6692733764648438 1.02
yew-struct-keyed 24_run5-memory 1.7057380676269531 1.710796356201172 1.00
yew-struct-keyed 25_run-clear-memory 1.3268890380859375 1.328044891357422 1.00
yew-struct-keyed 31_startup-ci 1729.632 1731.036 1.00
yew-struct-keyed 32_startup-bt 24.028 38.767999999999994 0.62
yew-struct-keyed 33_startup-mainthreadcost 190.556 261.37600000000003 0.73
yew-struct-keyed 34_startup-totalbytes 328.7412109375 328.7412109375 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.