Last active
April 21, 2020 04:22
-
-
Save digi0ps/f70e9c1977633470055327a726f97b30 to your computer and use it in GitHub Desktop.
Shell script for testing Postgres with and without an active connection.
This file contains hidden or 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
#! /bin/zsh | |
zmodload zsh/datetime | |
start=$EPOCHREALTIME | |
for i in {1..100}; | |
do | |
PGPASSWORD=password psql -U localadmin testing -c "select count(*) from pg_stat_activity;" > /dev/null; | |
done | |
end=$EPOCHREALTIME | |
echo "Test 1 Elapsed Time: $((end-start))"; | |
start=$EPOCHREALTIME | |
PGPASSWORD=password psql -U localadmin testing \ | |
-c "DO | |
\$do\$ | |
BEGIN | |
FOR i IN 1..100 LOOP | |
perform count(*) from pg_stat_activity; | |
END LOOP; | |
END | |
\$do\$;" > /dev/null; | |
end=$EPOCHREALTIME | |
echo "Test 2 Elapsed Time: $((end-start))"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment