feat: add zero-cost performance benchmark workflow
This commit is contained in:
1 parent
54851fc191
commit
5293d93a30
17 files changed
+1366
-8
No files matched your search
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
env_file="${1:-${repo_root}/compose/.env}"
|
||||
run_id="${2:-$(date +%Y%m%d-%H%M%S)}"
|
||||
output_root="${repo_root}/results/raw/${run_id}"
|
||||
compose_file="${repo_root}/compose/docker-compose.backend.yml"
|
||||
|
||||
if [[ ! -f "$env_file" ]]; then
|
||||
echo "Environment file not found: $env_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read_value() {
|
||||
local key="$1"
|
||||
sed -n "s/^${key}=//p" "$env_file" | head -n 1
|
||||
}
|
||||
|
||||
project_name="$(read_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||
profile="$(read_value TRIPO3D_MOCK_PROFILE)"
|
||||
if [[ -z "$project_name" ]]; then
|
||||
echo "BACKEND_COMPOSE_PROJECT_NAME is missing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compose_command=(
|
||||
docker compose
|
||||
--project-name "$project_name"
|
||||
--env-file "$env_file"
|
||||
-f "$compose_file"
|
||||
)
|
||||
|
||||
bash "${repo_root}/scripts/verify-tripo-mock.sh" "$env_file"
|
||||
mkdir -p "$output_root"
|
||||
sampler_stop="${output_root}/.resource-sampler-stop"
|
||||
rm -f "$sampler_stop"
|
||||
bash "${repo_root}/scripts/sample-benchmark-resources.sh" "$sampler_stop" \
|
||||
> "${output_root}/resources-during-tripo-mock.csv" &
|
||||
sampler_pid=$!
|
||||
|
||||
stop_sampler() {
|
||||
touch "$sampler_stop"
|
||||
wait "$sampler_pid" 2>/dev/null || true
|
||||
rm -f "$sampler_stop"
|
||||
}
|
||||
trap stop_sampler EXIT
|
||||
|
||||
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||
> "${output_root}/tripo-mock-snapshot-before.txt"
|
||||
|
||||
container_id="$("${compose_command[@]}" ps -q backend)"
|
||||
if [[ -z "$container_id" ]]; then
|
||||
echo "Backend container is not running." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
container_result="/tmp/tripo-mock-${run_id}.json"
|
||||
"${compose_command[@]}" exec -T backend python \
|
||||
/app/tools/tripo_mock_benchmark.py \
|
||||
--output "$container_result"
|
||||
docker cp "${container_id}:${container_result}" \
|
||||
"${output_root}/tripo-mock-${profile}.json"
|
||||
|
||||
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||
> "${output_root}/tripo-mock-snapshot-after.txt"
|
||||
|
||||
stop_sampler
|
||||
trap - EXIT
|
||||
|
||||
echo "Tripo mock benchmark completed: ${output_root}/tripo-mock-${profile}.json"
|
||||
Reference in new issue
Block a user