Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
60 lines (49 loc) · 2.27 KB
/
Copy pathjustfile
File metadata and controls
60 lines (49 loc) · 2.27 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
set shell := ["bash", "-cu"]
default:
@just --list
release *args:
@./scripts/release.sh {{args}}
test:
cmake --build build -j {{num_cpus()}} --target peglib-test-main
build/test/peglib-test-main
CPPPEGLIB_TEST_BLOB_ROUNDTRIP=1 build/test/peglib-test-main
bench:
#!/usr/bin/env bash
set -euo pipefail
# Build
cmake --build build --target benchmark >/dev/null 2>&1
# Run cpp-peglib
cpp_out=$(build/benchmark/benchmark 10 2>&1)
# Extract medians (field after "median:")
extract() { echo "$1" | grep "$2" | grep "median:" | head -1 | sed 's/.*median: *\([0-9.]*\) ms.*/\1/'; }
cpp_q1=$(extract "$cpp_out" "PEG: TPC-H Q1")
cpp_tpch=$(extract "$cpp_out" "PEG: all TPC-H")
cpp_big=$(extract "$cpp_out" "PEG: big.sql")
cpp_opt=$(extract "$cpp_out" "PEG-opt: big.sql")
yacc_q1=$(extract "$cpp_out" "YACC: TPC-H Q1")
yacc_tpch=$(extract "$cpp_out" "YACC: all TPC-H")
yacc_big=$(extract "$cpp_out" "YACC: big.sql")
# Ratios vs YACC (big.sql)
ratio_cpp=$(echo "scale=1; $cpp_big / $yacc_big" | bc)
ratio_opt=$(echo "scale=1; $cpp_opt / $yacc_big" | bc)
# Bar widths (max 40 chars, scaled to slowest)
max=$cpp_big
bar() {
local val=$1 width=$(echo "scale=0; $1 * 40 / $max" | bc)
printf '%*s' "$width" '' | tr ' ' '█'
}
echo ""
echo "================================================================"
echo " PEG SQL Benchmark (n=10, median ms)"
echo "================================================================"
printf "%-28s %8s %8s %8s\n" "" "TPC-H Q1" "all TPC-H" "big.sql"
echo "----------------------------------------------------------------"
printf "%-28s %8s %8s %8s\n" "cpp-peglib" "$cpp_q1" "$cpp_tpch" "$cpp_big"
printf "%-28s %8s %8s %8s\n" "cpp-peglib (optimized)" "" "" "$cpp_opt"
printf "%-28s %8s %8s %8s\n" "YACC (libpg_query)" "$yacc_q1" "$yacc_tpch" "$yacc_big"
echo ""
echo " big.sql:"
printf " YACC %6s ms |%-40s| 1.0x\n" "$yacc_big" "$(bar $yacc_big)"
printf " cpp-peglib (opt) %6s ms |%-40s| ${ratio_opt}x\n" "$cpp_opt" "$(bar $cpp_opt)"
printf " cpp-peglib %6s ms |%-40s| ${ratio_cpp}x\n" "$cpp_big" "$(bar $cpp_big)"
echo "================================================================"