forked from yewstack/yew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_benchmark_ssr_cmt.py
56 lines (36 loc) · 1.29 KB
/
make_benchmark_ssr_cmt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from typing import Dict, List, Optional, Tuple
import os
import json
header = "| Benchmark | Round | Min (ms) | Max (ms) | Mean (ms) | Standard Deviation |"
sep = "| --- | --- | --- | --- | --- | --- |"
def write_benchmark(lines: List[str], content: List[Dict[str, str]]) -> None:
lines.append("<details>")
lines.append("")
lines.append(header)
lines.append(sep)
for i in content:
lines.append(
"| {i.name} | {i.round} | {i.min} | {i.max} | {i.mean} | {i.std_dev} |"
)
lines.append("")
lines.append("</details>")
def main() -> None:
with open("benchmark-ssr/yew-master/output.json") as f:
master_content = json.loads(f.read())
with open("benchmark-ssr/current-pr/output.json") as f:
pr_content = json.loads(f.read())
lines: List[str] = []
lines.append("### Benchmark - SSR")
lines.append("")
lines.append("#### Yew Master")
lines.append("")
write_benchmark(lines, master_content)
lines.append("#### Pull Request")
lines.append("")
write_benchmark(lines, pr_content)
output = "\n".join(lines)
with open(os.environ["GITHUB_ENV"], "a+") as f:
f.write(f"YEW_BENCH_SSR={json.dumps(output)}\n")
f.write(f"PR_NUMBER={issue_number}\n")
if __name__ == "__main__":
main()