-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPUtestAllAlgo.sh
executable file
·74 lines (62 loc) · 2.16 KB
/
CPUtestAllAlgo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
PGHOST=172.17.0.2
PGUSER=postgres
PGDB=cryptobench
DATAFOLDER=data
SARFILE=${DATAFOLDER}/sacfile
ENTRIES=${DATAFOLDER}/stats.csv
THREADS=$(lscpu | awk '/^CPU\(s\):/ {print $2}')
# For the sar output.
LC_ALL=C
S_TIME_FORMAT=ISO
function execSQL ()
{
#--output=/dev/null
# Using heredoc as the timing does not work with -c option and > /dev/null
# as the redirection for the timing is merelly an output (it can't be redirected).
# Possible solution, regexp. No thanks, now.
psql "postgresql://${PGUSER}@${PGHOST}/${PGDB}?application_name=test" -n --output=/dev/null $4 <<EOF |
\timing
select
convert_from(pgp_sym_decrypt_bytea(pgp_sym_encrypt_bytea((\$\$Text to be encrypted using pgp_sym_decrypt_bytea\$\$::bytea
|| ((gen_random_uuid())::text)::bytea), 'key'::text, 'compress-algo=$1, compress-level=$2, cipher-algo=$3'::text), 'key'::text), 'SQL-ASCII'::name) from generate_series(1,1000);
EOF
grep Time | tr ',' '.' | awk '{ print "'"$3"'" ","'$1'","'$2'"," $2 }' >> $ENTRIES &
CURTHD=$5
if [ $CURTHD -gt 0 ] ; then
execSQL $1 $2 $3 $4 $(( CURTHD - 1 ))
fi
#Benchmarking bf with 0, level 0, DB cryptobench
#Time: 16707,233 ms
}
mv -f $ENTRIES ${ENTRIES}_$(date +%s) 2> /dev/null
touch $ENTRIES
for algo in bf aes128 aes192 aes256 3des ; do
LC_ALL=C /usr/lib/sysstat/sadc -S XALL 1 50 ${SARFILE}_$algo &
pid_sadc=$!
for ca in $(seq 0 2) ; do # compress-algo = 2 is Zlib with CRCs and metadata, should not affect the current test
if [ $ca -eq 0 ]
then
execSQL $ca 0 $algo $PGDB $THREADS
while [ $(psql -Upostgres -h172.17.0.2 -tnA -c 'select count(*) from pg_stat_activity where application_name ~ $$test$$') -gt 0 ]
do
sleep 1
done
continue
fi
for lev in $(seq 1 4 9) ; do
#echo "Benchmarking $algo with $ca, level $lev"
execSQL $ca $lev $algo $PGDB $THREADS
while [ $(psql -Upostgres -h172.17.0.2 -tnA -c 'select count(*) from pg_stat_activity where application_name ~ $$test$$') -gt 0 ]
do
sleep 1
done
#sync && echo 3 > /proc/sys/vm/drop_caches
done
done
kill $pid_sadc >& /dev/null
done
# Added to convert into kSar format.
for i in $(ls ${SARFILE}* ); do
LC_ALL=C sar -A -f $i >> "${i}_ksar"
done