summaryrefslogtreecommitdiff
path: root/scripts/compare-with-raku.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-20 21:06:35 +0200
committerPaul Buetow <paul@buetow.org>2026-02-20 21:06:35 +0200
commit59e86c9fd39308bc6b632e02ecf4d37265dabc91 (patch)
tree20e865fa680df4cff10056fa238ad07d7c58f458 /scripts/compare-with-raku.sh
parent0441f47fd585812b9c1f98b8a3dbeee03aa70b03 (diff)
Add Go implementation (goprecords)v0.1.0
- cmd/goprecords: CLI with import, query, report-from-files, test - internal/goprecords: types, order, aggregate, db, report - internal/version: version constant (0.1.0) - SQLite import (repeatable: clears record table then inserts) - Magefile: Build, Test, Install, Uninstall - Table-driven unit tests; comparison script vs Raku guprecords - .gitignore: *.db, /goprecords binary Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'scripts/compare-with-raku.sh')
-rwxr-xr-xscripts/compare-with-raku.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/compare-with-raku.sh b/scripts/compare-with-raku.sh
new file mode 100755
index 0000000..924cc85
--- /dev/null
+++ b/scripts/compare-with-raku.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+# Compare goprecords (Go) output with guprecords (Raku) on the same stats dir.
+# Usage: ./scripts/compare-with-raku.sh [stats-dir]
+# Default stats-dir: ../uprecords/stats (relative to repo root) or set UPRECORDS_STATS.
+
+set -e
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+STATS="${1:-${UPRECORDS_STATS:-$REPO_ROOT/../uprecords/stats}}"
+RAKU_REPO="${GUPRECORDS_RAKU:-$REPO_ROOT/../guprecords}"
+
+if [ ! -d "$STATS" ]; then
+ echo "Stats dir not found: $STATS" >&2
+ echo "Usage: $0 [stats-dir]" >&2
+ echo " or set UPRECORDS_STATS" >&2
+ exit 1
+fi
+if [ ! -f "$RAKU_REPO/guprecords.raku" ]; then
+ echo "Raku guprecords not found: $RAKU_REPO/guprecords.raku" >&2
+ echo "Set GUPRECORDS_RAKU to the guprecords (Raku) repo." >&2
+ exit 1
+fi
+
+GO_BIN="$REPO_ROOT/goprecords"
+if [ ! -x "$GO_BIN" ]; then
+ echo "Build goprecords first (e.g. mage build)" >&2
+ exit 1
+fi
+
+mkdir -p /tmp/goprecords-compare
+R=/tmp/goprecords-compare/raku
+G=/tmp/goprecords-compare/go
+
+echo "Stats dir: $STATS"
+echo "Raku repo: $RAKU_REPO"
+echo ""
+
+# Single report: Host Uptime
+echo "=== Host Uptime (limit 10) ==="
+raku "$RAKU_REPO/guprecords.raku" --stats-dir="$STATS" --category=Host --metric=Uptime --limit=10 --output-format=Plaintext 2>/dev/null > "$R.host_uptime.txt"
+"$GO_BIN" -stats-dir="$STATS" -category=Host -metric=Uptime -limit=10 -output-format=Plaintext 2>/dev/null > "$G.host_uptime.txt"
+if diff -q "$R.host_uptime.txt" "$G.host_uptime.txt" >/dev/null; then
+ echo "OK (identical)"
+else
+ diff -u "$R.host_uptime.txt" "$G.host_uptime.txt" || true
+fi
+
+# Single report: Host Boots, Markdown
+echo ""
+echo "=== Host Boots Markdown (limit 5) ==="
+raku "$RAKU_REPO/guprecords.raku" --stats-dir="$STATS" --category=Host --metric=Boots --limit=5 --output-format=Markdown 2>/dev/null > "$R.host_boots_md.txt"
+"$GO_BIN" -stats-dir="$STATS" -category=Host -metric=Boots -limit=5 -output-format=Markdown 2>/dev/null > "$G.host_boots_md.txt"
+if diff -q "$R.host_boots_md.txt" "$G.host_boots_md.txt" >/dev/null; then
+ echo "OK (identical)"
+else
+ diff -u "$R.host_boots_md.txt" "$G.host_boots_md.txt" || true
+fi
+
+# --all (known: description word-wrap may differ in one section)
+echo ""
+echo "=== --all limit 5 ==="
+raku "$RAKU_REPO/guprecords.raku" --stats-dir="$STATS" --all --limit=5 --output-format=Plaintext 2>/dev/null > "$R.all.txt"
+"$GO_BIN" -stats-dir="$STATS" -all -limit=5 -output-format=Plaintext 2>/dev/null > "$G.all.txt"
+if diff -q "$R.all.txt" "$G.all.txt" >/dev/null; then
+ echo "OK (identical)"
+else
+ echo "Differences (often only description word-wrap):"
+ diff -u "$R.all.txt" "$G.all.txt" | head -40 || true
+fi
+
+echo ""
+echo "Done. Raku output: $R.*.txt Go output: $G.*.txt"