Files
spring-boot-demo/aot-cache/scripts/lib.sh
T
Claude 3e2029ab3a Add aot-cache module: the JDK 25 AOT cache on Spring Boot 4.1 vs AppCDS, Spring AOT and GraalVM native
A Spring Boot 4.1.1 order service started 12 ways (plain and extracted jar, Spring AOT output, AppCDS, AOT cache trained with and without traffic, JDK 27, native image), ten interleaved rounds each, with first-request latency; 24 cache-mismatch cases; Docker layer arithmetic. Transcripts are in output/ (no docs/ folder).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
2026-09-24 16:44:16 +00:00

47 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start / probe / stop helpers shared by the measurement scripts.
source "$(dirname "${BASH_SOURCE[0]}")/env.sh"
PORT=18110
BODY='{"customer":"[email protected]","sku":"ABC-1234","quantity":3}'
now_ms() { echo $(( $(date +%s%N) / 1000000 )); }
# start_app WORKDIR LOGFILE cmd args... -> sets APP_PID (the java/native process itself, thanks to exec)
start_app() {
local wd=$1 log=$2; shift 2
( cd "$wd" && exec "$@" ) > "$log" 2>&1 &
APP_PID=$!
}
# wait_ready -> 0 when GET /ping answers 200 within 60 s
wait_ready() {
local i
for i in $(seq 1 3000); do
curl -sf -o /dev/null --max-time 2 "localhost:$PORT/ping" && return 0
kill -0 "$APP_PID" 2>/dev/null || return 1
sleep 0.02
done
return 1
}
stop_app() {
kill "$APP_PID" 2>/dev/null
wait "$APP_PID" 2>/dev/null
return 0
}
# ms_of SECONDS -> milliseconds with one decimal
ms_of() { awk -v s="$1" 'BEGIN{printf "%.1f", s*1000}'; }
# post_order -> prints curl's time_total in ms
post_order() {
ms_of "$(curl -s -o /dev/null -w '%{time_total}' -H 'Content-Type: application/json' -d "$BODY" "localhost:$PORT/orders")"
}
get_order() { ms_of "$(curl -s -o /dev/null -w '%{time_total}' "localhost:$PORT/orders/1")"; }
rss_mb() { awk '/VmRSS/ {printf "%d", $2/1024}' "/proc/$APP_PID/status"; }
median() { sort -n | awk '{a[NR]=$1} END{ if (NR==0) {print "n/a"; exit} if (NR%2) printf "%s", a[(NR+1)/2]; else printf "%.1f", (a[NR/2]+a[NR/2+1])/2 }'; }
minmax() { sort -n | awk 'NR==1{lo=$1} {hi=$1} END{printf "%s..%s", lo, hi}'; }