lab2: fix review round 2 — cache versioning, UUID normalization, cursor validation, ready deps
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
BASE=http://localhost:8080
|
||||
CHAT_ID=${1:?usage: $0 <chat_id> <token>}
|
||||
TOKEN=${2:?usage: $0 <chat_id> <token>}
|
||||
|
||||
echo "=== SQL/latency measurement ==="
|
||||
echo "Chat: $CHAT_ID"
|
||||
|
||||
# Сброс pg_stat_statements
|
||||
docker compose exec -T postgres psql -U messenger -d messenger -c \
|
||||
"CREATE EXTENSION IF NOT EXISTS pg_stat_statements;" > /dev/null
|
||||
docker compose exec -T postgres psql -U messenger -d messenger -c \
|
||||
"SELECT pg_stat_statements_reset();" > /dev/null
|
||||
|
||||
echo "--- Run WITH cache ---"
|
||||
hey -n 5000 -c 100 -H "Authorization: Bearer $TOKEN" \
|
||||
"$BASE/api/v1/chats/$CHAT_ID/messages?limit=50" > /tmp/cache_on.txt
|
||||
|
||||
SQL_ON=$(docker compose exec -T postgres psql -U messenger -d messenger -t -A -c \
|
||||
"SELECT COALESCE(SUM(calls),0) FROM pg_stat_statements WHERE query LIKE '%FROM messages%';")
|
||||
|
||||
echo "RPS (cache ON):"
|
||||
grep -E "Requests/sec" /tmp/cache_on.txt
|
||||
echo "p95 (cache ON):"
|
||||
grep -E "95%% in" /tmp/cache_on.txt
|
||||
echo "SQL queries (cache ON): $SQL_ON"
|
||||
|
||||
echo ""
|
||||
echo "--- Run WITHOUT cache (manually flush Redis before each request is impractical) ---"
|
||||
echo "To measure without cache: stop Redis, run hey, then start Redis."
|
||||
echo " docker compose stop redis"
|
||||
echo " hey -n 5000 -c 100 ..."
|
||||
echo " docker compose start redis"
|
||||
Reference in New Issue
Block a user