From 6e36220ed31b957796c255d9bbd7880bcca49c7c Mon Sep 17 00:00:00 2001 From: Maciek Sakrejda Date: Thu, 12 Jul 2012 14:35:14 -0700 Subject: [PATCH] Performance smoke test. --- .gitignore | 1 + perf-smoke.config.sample | 8 +++++++ perf-smoke.sh | 46 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 .gitignore create mode 100644 perf-smoke.config.sample create mode 100755 perf-smoke.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e259b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +perf-smoke.config diff --git a/perf-smoke.config.sample b/perf-smoke.config.sample new file mode 100644 index 0000000..d449e48 --- /dev/null +++ b/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 diff --git a/perf-smoke.sh b/perf-smoke.sh new file mode 100755 index 0000000..8f29b75 --- /dev/null +++ b/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