Created
October 22, 2012 21:06
-
-
Save karoun/3934300 to your computer and use it in GitHub Desktop.
A slightly improved benchmarking script for HW3 in CS186 (Fall 2012)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Original concept/script by Colin Chang | |
# Slight improvements by Karoun Kasraie | |
commands=$(cat <<EOF | |
SELECT * FROM raw_r_tuples; | |
SELECT * FROM raw_r_tuples; | |
SELECT * FROM raw_r_tuples; | |
SELECT * FROM raw_r_tuples r, raw_s_tuples s WHERE r.pkey = s.pkey; | |
SELECT * FROM raw_r_tuples r, raw_s_tuples s WHERE r.pkey = s.pkey; | |
SELECT * FROM raw_r_tuples r, raw_s_tuples s WHERE r.pkey = s.pkey; | |
EOF | |
) | |
echo -n "Remaking and installing PostgreSQL from source... " | |
make -s > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Failed" | |
echo "Make sure you're running this script in postgresql-8.4.2/ and that \`make install\` succeeds." | |
exit 1 | |
fi | |
make -s install > /dev/null | |
echo "Done" | |
echo -n "Clearing performace.txt... " | |
cat /dev/null > performance.txt | |
echo "Done" | |
# loop through all combinations | |
for p in clock lru mru 2q; do | |
for n in 16 32 64 96; do | |
log="$p$n.log" | |
echo | |
echo $p$n | |
echo "==================================" | |
# clear any previous log | |
cat /dev/null > $log | |
echo -n "Starting PostgreSQL server... " | |
$HOME/pgsql/bin/pg_ctl start -D $HOME/pgsql/data -l $log -o "-p 11111 -B $n -N 1 -o '-te -fm -fh' --buffer-replacement-policy=$p --autovacuum=off" > /dev/null | |
sleep 1 | |
echo "Done" | |
echo -n "Running benchmarks... " | |
$HOME/pgsql/bin/psql -p 11111 -d postgres -c "$commands" > /dev/null | |
echo "Done" | |
echo -n "Stopping PostgreSQL server... " | |
$HOME/pgsql/bin/pg_ctl stop -D ~/pgsql/data > /dev/null | |
sleep 1 | |
echo "Done" | |
echo -n "Writing to performance.txt... " | |
echo -n "$p $n " >> performance.txt | |
echo -n $(grep Shared $log | awk '{print $12}' | tr -d %) >> performance.txt | |
echo >> performance.txt | |
echo "Done" | |
done | |
done | |
echo | |
echo "Benchmark results:" | |
cat performance.txt | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment