Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
mutants.out*/
target-thin/
70 changes: 27 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions benchmarks/real-world/config-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Simulated configuration linter.
#
# Models a CI-side validation tool: for each config entry, a fresh getopts
# pass parses that entry's option string, followed by declaration-heavy
# checks and formatted reporting. Deterministic output.
#
# Usage: config-lint.sh [count]
# count number of config entries to validate (default 250)

set -eu

COUNT=${1:-250}

total=0
warnings=0
errors=0
strict=no
prefix="."

validate() {
local id=$1
shift

local path=$prefix scope=global mode=read-only verbose=no bad=0
local opt err=0

while getopts ":p:s:m:v" opt "$@"; do
case "$opt" in
p) path=$OPTARG ;;
s) scope=$OPTARG ;;
m) mode=$OPTARG ;;
v) verbose=yes ;;
\?) err=1 ; break ;;
esac
done

# Validation rules (pure builtin work: patterns, substring ops, arithmetic).
case "$scope" in
global|user|session) ;;
*) bad=$((bad + 1)) ;;
esac
case "$mode" in
read-only|read-write) ;;
*) bad=$((bad + 1)) ;;
esac
if [ "${#path}" -gt 64 ]; then
bad=$((bad + 1))
fi
if [ "$((id % 7))" -eq 0 ]; then
warnings=$((warnings + 1))
fi

if [ "$verbose" = yes ]; then
printf 'entry %03d: path=%s scope=%-8s mode=%-10s\n' \
"$id" "$path" "$scope" "$mode"
fi

if [ "$bad" -gt 0 ]; then
errors=$((errors + bad))
printf 'entry %03d: %d problem(s)\n' "$id" "$bad"
fi

total=$((total + 1))
}

i=0
while [ "$i" -lt "$COUNT" ]; do
i=$((i + 1))
case $((i % 3)) in
0) validate "$i" -p "/etc/app/svc$i.conf" -s user -m read-write -v ;;
1) validate "$i" -p "/var/lib/app/$i.db" -m read-only ;;
2) validate "$i" -s session -m read-write -v ;;
esac
done

printf 'checked %d entries: %d warning(s), %d error(s)\n' \
"$COUNT" "$warnings" "$errors"
[ "$errors" -eq 0 ]
128 changes: 128 additions & 0 deletions benchmarks/real-world/deploy-sim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env bash
# Simulated multi-target deployment script.
#
# A deliberately "typical" operations script: option parsing, directory
# juggling, declarations, formatted reporting. Deterministic by construction
# (no timestamps, no randomness) so two shells can be diffed byte-for-byte.
#
# Builtin-parse density comes from the per-artifact loop: every iteration
# re-parses getopts-style option handling plus declare/local/printf/test calls.

set -euo pipefail

TARGET=""
JOBS=4
VERBOSE=0
DRY_RUN=no
COMPRESS=gzip
TAG="latest"
VERSION=2

usage() {
printf 'usage: %s [-v] [-n] [-j jobs] [-c compressor] [-t tag] target\n' "$0" >&2
}

die() {
printf 'deploy: error: %s\n' "$1" >&2
exit 2
}

[ $# -gt 0 ] || { usage; exit 2; }

while getopts ":vnj:c:t:h-" opt; do
case "$opt" in
v) VERBOSE=$((VERBOSE + 1)) ;;
n) DRY_RUN=yes ;;
j) JOBS=$OPTARG
case "$JOBS" in (*[!0-9]*|'') die "-j expects a number" ;; esac ;;
c) COMPRESS=$OPTARG ;;
t) TAG=$OPTARG ;;
h) usage; exit 0 ;;
-) break ;;
\?) die "invalid option: -$OPTARG" ;;
esac
done
shift $((OPTIND - 1))

TARGET=${1:?missing target argument}
case "$TARGET" in
staging|production|canary) ;;
*) die "unknown target '$TARGET'" ;;
esac

WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT

mkdir "$WORK/pkg" "$WORK/out" "$WORK/cache"

pushd "$WORK" > /dev/null
trap 'popd > /dev/null; rm -rf "$WORK"' EXIT

ARTIFACTS=(
"core:1.0.${VERSION}:stable"
"cli:1.2.${VERSION}:stable"
"daemon:0.9.${VERSION}:beta"
"web:2.3.${VERSION}:beta"
"tools:0.0.${VERSION}:experimental"
)

report_row() {
local name=$1 version=$2 channel=$3 size=$4 status=$5
printf '| %-8s | %-8s | %-12s | %6d KiB | %-8s |\n' \
"$name" "$version" "$channel" "$size" "$status"
}

build_artifact() {
local spec=$1
local name=${spec%%:*}
local rest=${spec#*:}
local version=${rest%%:*}
local channel=${rest##*:}

# Local scope + string manipulation per artifact.
local pkg_dir="$WORK/pkg/$name"
mkdir -p "$pkg_dir"
printf '%s %s (%s)\nbuilt for %s with %s\n' \
"$name" "$version" "$channel" "$TARGET" "$COMPRESS" \
> "$pkg_dir/README"

local size=0
while read -r line; do
size=$((size + ${#line}))
done < "$pkg_dir/README"

if [ "$DRY_RUN" = yes ]; then
status=skipped
else
tar -cf - -C "$pkg_dir" . 2>/dev/null | wc -c > /dev/null
status=built
fi

report_row "$name" "$version" "$channel" "$size" "$status"
}

printf 'deploy plan for %s (jobs=%d, dry-run=%s, verbosity=%d)\n' \
"$TARGET" "$JOBS" "$DRY_RUN" "$VERBOSE"
printf '+----------+----------+--------------+-----------+----------+\n'
printf '| name | version | channel | size | status |\n'
printf '+----------+----------+--------------+-----------+----------+\n'

for spec in "${ARTIFACTS[@]}"; do
build_artifact "$spec"
done

printf '+----------+----------+--------------+-----------+----------+\n'

# Directory bookkeeping round-trip.
for d in pkg out cache; do
pushd "$d" > /dev/null
pwd > /dev/null
popd > /dev/null
done

# Export checks: environment visible to a fresh shell.
export DEPLOY_TARGET="$TARGET" DEPLOY_TAG="$TAG"
env | grep '^DEPLOY_' | LC_ALL=C sort
unset DEPLOY_TARGET DEPLOY_TAG

echo "done"
12 changes: 12 additions & 0 deletions benchmarks/real-world/interp-loop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Pure-interpretation loop: assignments and arithmetic, no external commands,
# no builtin argument parsing. Isolates interpreter cost from parser cost.

set -eu

x=0
for ((i = 0; i < 60000; i++)); do
x=$((x + i % 7))
done

printf '%d\n' "$x"
Loading
Loading