-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathformat_bench_summary
More file actions
executable file
·38 lines (33 loc) · 1.31 KB
/
Copy pathformat_bench_summary
File metadata and controls
executable file
·38 lines (33 loc) · 1.31 KB
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
#!/bin/bash
set -euo pipefail
{
echo "## Benchmark Results"
echo ""
echo "| Benchmark | Mean | Std Dev |"
echo "|-----------|------|---------|"
find target/criterion -path "*/new/estimates.json" -type f | sort | while read -r estimate_file; do
# Path format: target/criterion/{group}/prism/{name}/new/estimates.json
group=$(echo "$estimate_file" | cut -d'/' -f3)
name=$(echo "$estimate_file" | cut -d'/' -f5)
# Parse JSON and format with appropriate unit
result=$(ruby -rjson -e "
def format_time(ns)
if ns >= 1_000_000_000
format('%.2fs', ns / 1_000_000_000.0)
elsif ns >= 1_000_000
format('%.2fms', ns / 1_000_000.0)
elsif ns >= 1_000
format('%.2fµs', ns / 1_000.0)
else
format('%.2fns', ns)
end
end
d = JSON.parse(File.read('$estimate_file'))
mean = format_time(d['mean']['point_estimate'])
std = format_time(d['mean']['standard_error'])
puts \"#{mean} #{std}\"
" 2>/dev/null) || continue
read -r mean std <<< "$result"
echo "| ${group}/${name} | ${mean} | ±${std} |"
done
} >> "${GITHUB_STEP_SUMMARY:-/dev/stdout}"