feat: add zero-cost performance benchmark workflow
This commit is contained in:
1 parent
54851fc191
commit
5293d93a30
17 files changed
+1366
-8
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Summarize HTTP benchmark JSON files as Markdown.")
|
||||
parser.add_argument("directory")
|
||||
parser.add_argument("--output")
|
||||
args = parser.parse_args()
|
||||
|
||||
directory = pathlib.Path(args.directory)
|
||||
rows = []
|
||||
for path in sorted(directory.glob("*.json")):
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
latency = payload.get("latency_ms") or {}
|
||||
rows.append(
|
||||
(
|
||||
path.stem,
|
||||
payload.get("concurrency"),
|
||||
payload.get("requests"),
|
||||
payload.get("successful_requests"),
|
||||
payload.get("failed_requests"),
|
||||
payload.get("requests_per_second"),
|
||||
latency.get("p50"),
|
||||
latency.get("p95"),
|
||||
latency.get("p99"),
|
||||
latency.get("max"),
|
||||
)
|
||||
)
|
||||
|
||||
if not rows:
|
||||
raise SystemExit(f"No benchmark JSON files found in: {directory}")
|
||||
|
||||
lines = [
|
||||
"| 场景 | 并发 | 请求数 | 成功 | 失败 | RPS | P50 ms | P95 ms | P99 ms | 最大 ms |",
|
||||
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |",
|
||||
]
|
||||
for row in rows:
|
||||
lines.append("| " + " | ".join(str(value) for value in row) + " |")
|
||||
rendered = "\n".join(lines) + "\n"
|
||||
print(rendered, end="")
|
||||
if args.output:
|
||||
output_path = pathlib.Path(args.output)
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
output_path.write_text(rendered, encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user