benchmark.sh
text/x-patch
#! /bin/sh
psql bench <<"EOF"
create or replace function bench(scale int, reps int) returns void
language plpgsql
as $$
declare
naccounts int := 100000 * scale;
v_aid int;
v_abalance int;
begin
for i in 1 .. reps loop
v_aid := round(random() * naccounts + 1);
SELECT abalance INTO v_abalance FROM pgbench_accounts WHERE aid = v_aid;
end loop;
end;
$$;
EOF
cat >bench.script <<EOF
select bench(:scale, 1000);
EOF
# warm the caches a bit
pgbench -c 1 -j 1 -f bench.script -T 30 bench >/dev/null
echo pgbench -c 1 -j 1 -f bench.script -T 300 bench
pgbench -c 1 -j 1 -f bench.script -T 300 bench | grep including
echo pgbench -c 2 -j 1 -f bench.script -T 300 bench
pgbench -c 2 -j 1 -f bench.script -T 300 bench | grep including
echo pgbench -c 8 -j 4 -f bench.script -T 300 bench
pgbench -c 8 -j 4 -f bench.script -T 300 bench | grep including
echo pgbench -c 16 -j 8 -f bench.script -T 300 bench
pgbench -c 16 -j 8 -f bench.script -T 300 bench | grep including
echo pgbench -c 32 -j 16 -f bench.script -T 300 bench
pgbench -c 32 -j 16 -f bench.script -T 300 bench | grep including
echo pgbench -c 64 -j 32 -f bench.script -T 300 bench
pgbench -c 64 -j 32 -f bench.script -T 300 bench | grep including
echo pgbench -c 96 -j 48 -f bench.script -T 300 bench
pgbench -c 96 -j 48 -f bench.script -T 300 bench | grep including
echo pgbench -c 128 -j 64 -f bench.script -T 300 bench
pgbench -c 128 -j 64 -f bench.script -T 300 bench | grep including