fix regression from upstream merge conflict resoultion preventing non-amalgamated...
[sqlcipher.git] / tool / speed-check.sh
blob96025920d31a04296653777e0273a9298f0e6e92
1 #!/bin/bash
3 # This is a template for a script used for day-to-day size and
4 # performance monitoring of SQLite. Typical usage:
6 # sh run-speed-test.sh trunk # Baseline measurement of trunk
7 # sh run-speed-test.sh x1 # Measure some experimental change
8 # fossil test-diff --tk cout-trunk.txt cout-x1.txt # View chanages
10 # There are multiple output files, all with a base name given by
11 # the first argument:
13 # summary-$BASE.txt # Copy of standard output
14 # cout-$BASE.txt # cachegrind output
15 # explain-$BASE.txt # EXPLAIN listings (only with --explain)
17 if test "$1" = ""
18 then
19 echo "Usage: $0 OUTPUTFILE [OPTIONS]"
20 exit
22 NAME=$1
23 shift
24 #CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
25 CC_OPTS="-DSQLITE_ENABLE_MEMSYS5"
26 CC=gcc
27 SPEEDTEST_OPTS="--shrink-memory --reprepare --stats --heap 10000000 64"
28 SIZE=5
29 LEAN_OPTS="-DSQLITE_THREADSAFE=0"
30 LEAN_OPTS="$LEAN_OPTS -DSQLITE_DEFAULT_MEMSTATUS=0"
31 LEAN_OPTS="$LEAN_OPTS -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1"
32 LEAN_OPTS="$LEAN_OPTS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS"
33 LEAN_OPTS="$LEAN_OPTS -DSQLITE_MAX_EXPR_DEPTH=0"
34 LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_DECLTYPE"
35 LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_DEPRECATED"
36 LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_PROGRESS_CALLBACK"
37 LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_SHARED_CACHE"
38 LEAN_OPTS="$LEAN_OPTS -DSQLITE_USE_ALLOCA"
39 BASELINE="trunk"
40 doExplain=0
41 doCachegrind=1
42 doVdbeProfile=0
43 doWal=1
44 doDiff=1
45 while test "$1" != ""; do
46 case $1 in
47 --nodiff)
48 doDiff=0
50 --reprepare)
51 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
53 --autovacuum)
54 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
56 --utf16be)
57 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
59 --stats)
60 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
62 --without-rowid)
63 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
65 --nomemstat)
66 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
68 --temp)
69 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6"
71 --legacy)
72 doWal=0
74 --wal)
75 doWal=1
77 --size)
78 shift; SIZE=$1
80 --cachesize)
81 shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --cachesize $1"
83 --explain)
84 doExplain=1
86 --vdbeprofile)
87 rm -f vdbe_profile.out
88 CC_OPTS="$CC_OPTS -DVDBE_PROFILE"
89 doCachegrind=0
90 doVdbeProfile=1
92 --lean)
93 CC_OPTS="$CC_OPTS $LEAN_OPTS"
95 --clang)
96 CC=clang
98 --icc)
99 CC=/home/drh/intel/bin/icc
101 --gcc7)
102 CC=gcc-7
104 --heap)
105 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
106 shift;
107 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
109 --lookaside)
110 shift;
111 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2"
112 shift;
114 --repeat)
115 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE"
116 shift;
117 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --repeat $1"
119 --mmap)
120 shift;
121 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1"
123 --rtree)
124 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
125 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
127 --orm)
128 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
130 --cte)
131 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
133 --fp)
134 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
137 CC_OPTS="$CC_OPTS $1"
140 BASELINE=$1
142 esac
143 shift
144 done
145 if test $doWal -eq 1; then
146 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
148 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE"
149 echo "NAME = $NAME" | tee summary-$NAME.txt
150 echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt
151 echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
152 rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
153 if test $doVdbeProfile -eq 1; then
154 rm -f vdbe_profile.out
156 $CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
157 size sqlite3.o | tee -a summary-$NAME.txt
158 if test $doExplain -eq 1; then
159 $CC -g -Os -Wall -I. $CC_OPTS \
160 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
161 ./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
163 SRC=./speedtest1.c
164 $CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
165 ls -l speedtest1 | tee -a summary-$NAME.txt
166 if test $doCachegrind -eq 1; then
167 valgrind --tool=cachegrind ./speedtest1 speedtest1.db \
168 $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
169 else
170 ./speedtest1 speedtest1.db $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
172 size sqlite3.o | tee -a summary-$NAME.txt
173 wc sqlite3.c
174 if test $doCachegrind -eq 1; then
175 cg_anno.tcl cachegrind.out.* >cout-$NAME.txt
176 echo '*****************************************************' >>cout-$NAME.txt
177 sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>cout-$NAME.txt
179 if test $doExplain -eq 1; then
180 ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
182 if test $doVdbeProfile -eq 1; then
183 tclsh ../sqlite/tool/vdbe_profile.tcl >vdbeprofile-$NAME.txt
184 open vdbeprofile-$NAME.txt
186 if test "$NAME" != "$BASELINE" -a $doVdbeProfile -ne 1 -a $doDiff -ne 0; then
187 fossil test-diff --tk -c 20 cout-$BASELINE.txt cout-$NAME.txt