Skip to content

Commit 10ae4a1

Browse files
EzrealJxljiulang
authored andcommitted
update github action
1 parent 2253c5a commit 10ae4a1

File tree

2 files changed

+24
-60
lines changed

2 files changed

+24
-60
lines changed
Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Benchmark Results Summary Script
4-
# 用于从 BenchmarkDotNet JSON 结果中提取关键性能指标
4+
# 直接从 BenchmarkDotNet 生成的 Markdown 报告中提取结果
55

66
echo "# Benchmark Results Summary"
77
echo ""
@@ -19,59 +19,24 @@ for fw in "${frameworks[@]}"; do
1919
echo "### Framework: ${fw}"
2020
echo ""
2121

22-
# 查找 JSON 结果文件
23-
json_files=$(find "$result_dir" -name "*.json" -type f 2>/dev/null)
22+
# 查找 Markdown 报告文件
23+
md_files=$(find "$result_dir" -name "*-report-github.md" -type f 2>/dev/null)
2424

25-
if [ -n "$json_files" ]; then
26-
echo "Found benchmark results:"
27-
28-
for json_file in $json_files; do
29-
benchmark_name=$(basename "$json_file" .json)
30-
echo ""
25+
if [ -n "$md_files" ]; then
26+
for md_file in $md_files; do
27+
benchmark_name=$(basename "$md_file" -report-github.md)
3128
echo "#### $benchmark_name"
29+
echo ""
3230

33-
# 使用 jq 提取完整的关键指标(如果可用)
34-
if command -v jq &> /dev/null; then
35-
echo "| Method | Mean (μs) | Error (μs) | StdDev (μs) | Ratio | Gen0 | Allocated (KB) | Alloc Ratio |"
36-
echo "|--------|-----------|------------|-------------|-------|------|----------------|-------------|"
37-
38-
# 提取详细数据,转换单位
39-
jq -r '.Benchmarks[] |
40-
"| \(.Method) | \(
41-
if .Statistics.Mean then
42-
(.Statistics.Mean / 1000 | . * 100 | round / 100)
43-
else "N/A" end
44-
) | \(
45-
if .Statistics.StandardError then
46-
(.Statistics.StandardError / 1000 | . * 100 | round / 100)
47-
else "N/A" end
48-
) | \(
49-
if .Statistics.StandardDeviation then
50-
(.Statistics.StandardDeviation / 1000 | . * 100 | round / 100)
51-
else "N/A" end
52-
) | \(
53-
if .Ratio then
54-
(.Ratio | . * 100 | round / 100)
55-
else "N/A" end
56-
) | \(
57-
.Memory.Gen0Collections // "0"
58-
) | \(
59-
if .Memory.BytesAllocatedPerOperation then
60-
(.Memory.BytesAllocatedPerOperation / 1024 | . * 100 | round / 100)
61-
else "N/A" end
62-
) | \(
63-
if .Memory.AllocRatio then
64-
(.Memory.AllocRatio | . * 100 | round / 100)
65-
else "N/A" end
66-
) |"' "$json_file" 2>/dev/null || echo "Unable to parse JSON"
67-
else
68-
echo "⚠️ jq not available, showing file location: $json_file"
69-
echo ""
70-
echo "Please install jq to see detailed performance metrics."
71-
fi
31+
# 直接提取 Markdown 表格(从表头到空行)
32+
# 查找包含 "| Method" 的行,然后提取完整表格
33+
awk '/\| Method.*\|/ {found=1} found {print} /^$/ && found {exit}' "$md_file" |
34+
grep -v "^$" || echo "No table found in $md_file"
35+
36+
echo ""
7237
done
7338
else
74-
echo "No JSON results found in $result_dir"
39+
echo "No Markdown reports found in $result_dir"
7540
fi
7641

7742
echo ""
@@ -85,17 +50,19 @@ done
8550

8651
echo "## Performance Metrics Explanation"
8752
echo ""
88-
echo "- **Mean**: Average execution time in microseconds (μs)"
53+
echo "- **Mean**: Average execution time"
8954
echo "- **Error**: Half of 99.9% confidence interval"
9055
echo "- **StdDev**: Standard deviation of all measurements"
91-
echo "- **Ratio**: Mean of current method divided by baseline mean"
56+
echo "- **Ratio**: Performance ratio compared to baseline (lower is better for baseline)"
57+
echo "- **RatioSD**: Standard deviation of the Ratio"
9258
echo "- **Gen0**: GC Generation 0 collections per 1000 operations"
93-
echo "- **Allocated**: Total memory allocated per operation in kilobytes (KB)"
94-
echo "- **Alloc Ratio**: Allocated memory ratio compared to baseline"
59+
echo "- **Allocated**: Total memory allocated per operation"
60+
echo "- **Alloc Ratio**: Memory allocation ratio compared to baseline"
9561
echo ""
9662
echo "## Notes"
9763
echo ""
64+
echo "- **Baseline** method (marked with 🏆 or Ratio=1.00) is the reference point"
9865
echo "- Lower values are better for Mean, Error, StdDev, and Allocated"
99-
echo "- Ratio of 1.00 means equal performance to baseline (typically the first method)"
100-
echo "- Download the artifact 'benchmark-results' for detailed reports and raw JSON data"
66+
echo "- Ratio > 1.00 means slower/more memory than baseline"
67+
echo "- Download the artifact 'benchmark-results' for detailed reports and raw data"
10168
echo ""

.github/workflows/ci-benchmark.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,11 @@ jobs:
153153
echo "=== All Result Files ==="
154154
find . -path "*/BenchmarkDotNet.Artifacts*/results/*" -type f
155155
echo ""
156-
echo "=== Checking for JSON results ==="
157-
find . -path "*/BenchmarkDotNet.Artifacts*/results/*.json" -type f | while read file; do
156+
echo "=== Checking for Markdown reports ==="
157+
find . -path "*/BenchmarkDotNet.Artifacts*/results/*-report-github.md" -type f | while read file; do
158158
echo "Found: $file"
159159
echo "Size: $(du -h "$file" | cut -f1)"
160160
done
161-
echo ""
162-
echo "=== Directory Tree ==="
163-
ls -la BenchmarkDotNet.Artifacts.* 2>/dev/null || echo "No BenchmarkDotNet.Artifacts.* directories found in root"
164161
165162
# 生成详细的性能对比摘要(同时输出到 Summary 和文件)
166163
- name: Generate detailed benchmark summary

0 commit comments

Comments
 (0)