compare.sh
This file
Path
benchmarks/fetch/compare.sh
44 lines · 1.1 KiB · Shell
Last changed by
chore(benchmark): add app.fetch() overhead benchmark (#5117)Yusuke Wadabefore adoptionc285f9a
History of this fileTake it
chore(benchmark): add app.fetch() overhead benchmark (#5117)Yusuke Wadabefore adoptionc285f9a
lines 1–44why, one step back1#!/bin/bash2# Compare app.fetch() between the working tree and a git ref (default: main).3#4# Each measurement runs in a fresh process, and the variant order is5# reversed on every round, so that same-process JIT/GC warm-up and6# execution order do not bias the results.7#8# Usage: ./compare.sh [ref]9# RUNTIME=node ROUNDS=5 ./compare.sh [ref]10set -e11cd "$(dirname "$0")"1213REF=${1:-main}14RUNTIME=${RUNTIME:-bun}15ROUNDS=${ROUNDS:-3}16ROOT=$(git rev-parse --show-toplevel)17WT=$(mktemp -d)/hono-base18RESULTS=$(mktemp)1920cleanup() {21 git -C "$ROOT" worktree remove --force "$WT" 2>/dev/null || true22 rm -f "$RESULTS"23}24trap cleanup EXIT2526git -C "$ROOT" worktree add --detach -q "$WT" "$REF"2728run_variant() { # <label> <src>29 HONO_JSON=1 HONO_LABEL="$1" HONO_SRC="$2" $RUNTIME ./bench.mts >>"$RESULTS" 2>/dev/null30}3132for ((i = 1; i <= ROUNDS; i++)); do33 if ((i % 2)); then34 echo "round $i/$ROUNDS: $REF -> dev" >&235 run_variant "$REF" "$WT/src"36 run_variant "dev" "$ROOT/src"37 else38 echo "round $i/$ROUNDS: dev -> $REF" >&239 run_variant "dev" "$ROOT/src"40 run_variant "$REF" "$WT/src"41 fi42done4344$RUNTIME ./summarize.mts "$RESULTS" "$REF"