Skip to content

Commit

Permalink
Performance smoke test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciek Sakrejda committed Jul 13, 2012
1 parent 0ee013a commit 6e36220
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
perf-smoke.config
8 changes: 8 additions & 0 deletions perf-smoke.config.sample
@@ -0,0 +1,8 @@
#!/bin/bash

proxy_port=8432
PGB_CMD="env PGPORT=$proxy_port PGHOST=localhost PGSSLMODE=disable /usr/lib/postgresql/9.1/bin/pgbench -s 50 -i"
PROXY_BUILD="go build tools/simpleproxy.go"
PROXY_CMD="simpleproxy"
PROXY_ARGS="localhost:$proxy_port localhost:5432"
ITERATIONS=5
46 changes: 46 additions & 0 deletions perf-smoke.sh
@@ -0,0 +1,46 @@
#!/bin/bash

set -e
# A simple performance "smoke test" for femebe using simpleproxy
#
# This simply:
# 1. Starts (and times) a simpleproxy
# 2. Runs a pgbench test
# 3. Repeates designated number of times
# 4. Munges the numbers

if [ ! -f perf-smoke.config ]
then
cp perf-smoke.config.sample perf-smoke.config
fi

source perf-smoke.config

$PROXY_BUILD

for iter in $(seq $ITERATIONS)
do
env time -v --quiet -o run-${iter}.time ./${PROXY_CMD} $PROXY_ARGS &
# Give the pipeline time to kick everything off and
# the proxy time to start listening
sleep 1
# A little ugly: we want to stop the proxy, but because it's
# kicked off by go run, which is kicked off by time, which is
# kicked off by env, we don't have a terribly principled way of
# asking it to exit. Instead we find its pid (we assume it's the
# only one running) and send it a SIGINT
proxy_pid="$(pgrep $PROXY_CMD)"
$PGB_CMD
# This would normally be a SIGTERM, but this seems busted:
# I can't get even a toy program to respond to that signal.
# SIGINT works fine.
kill -INT $proxy_pid
done

cp run-1.time run-summary.time

for iter in $(seq 2 $ITERATIONS)
do
cp run-summary.time tmp
paste tmp <(sed -e '1s/.*//' -e's/.*://' run-${iter}.time) > run-summary.time
done

0 comments on commit 6e36220

Please sign in to comment.