forked from preslavrachev/gomjml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.sh
More file actions
executable file
·69 lines (61 loc) · 2.07 KB
/
Copy pathbench.sh
File metadata and controls
executable file
·69 lines (61 loc) · 2.07 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# MJML Benchmark Runner with Progress and Markdown Export
# Usage: ./bench.sh [--markdown|-m]
MARKDOWN=false
if [[ "$1" == "--markdown" || "$1" == "-m" ]]; then
MARKDOWN=true
fi
echo "🚀 Starting MJML benchmarks..."
echo "📊 Running comprehensive performance tests..."
# Process benchmark results - only run specific benchmarks
go test ./mjml -bench='BenchmarkMJMLRender_(10|100|1000)_Sections' -benchmem -run='^$' 2>/dev/null | awk -v markdown="$MARKDOWN" '
/^Benchmark/ {
if (/ns\/op.*B\/op.*allocs\/op/) {
# Has memory data
time_ns = $3
time_ms = time_ns / 1000000
bytes = $5
mb = bytes / (1024 * 1024)
allocs = $7
allocs_k = allocs / 1000
if (markdown == "true") {
printf "| %-33s | %6.2fms | %6.2fMB | %8.1fK |\n", $1, time_ms, mb, allocs_k
} else {
printf "%-35s %8.2fms %8.2fMB %10.1fK\n", $1, time_ms, mb, allocs_k
}
} else if (/ns\/op/) {
# Time only
time_ns = $3
time_ms = time_ns / 1000000
if (markdown == "true") {
printf "| %-33s | %6.2fms | %8s | %8s |\n", $1, time_ms, "-", "-"
} else {
printf "%-35s %8.2fms %8s %10s\n", $1, time_ms, "-", "-"
}
}
next
}
BEGIN {
if (markdown == "true") {
printf "| %-33s | %8s | %8s | %8s |\n", "Benchmark", "Time", "Memory", "Allocs"
printf "|%-34s|%9s|%9s|%9s|\n", ":---------------------------------", ":-------:", ":-------:", ":-------:"
} else {
printf "%-35s %8s %8s %10s\n", "Benchmark", "Time", "Memory", "Allocs"
printf "%-35s %8s %8s %10s\n", "---------", "----", "------", "------"
}
}' | if [[ "$MARKDOWN" == "false" ]]; then
if command -v column >/dev/null 2>&1; then
column -t
else
cat
fi
else
cat
fi
if [[ "$MARKDOWN" == "true" ]]; then
echo ""
echo "📋 Markdown table generated! Copy the output above to use in documentation."
else
echo ""
echo "💡 Tip: Use './bench.sh --markdown' to generate markdown table format"
fi