Merge trunk changes into this branch.
[sqlite.git] / tool / speed-check.sh
blob4cc25794a24f4fd034cfb1d6baa8754646d8d906
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 speed-check.sh trunk # Baseline measurement of trunk
7 # sh speed-check.sh x1 # Measure some experimental change
8 # fossil xdiff --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 --strict)
66 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
68 --nomemstat)
69 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
71 --multithread)
72 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
74 --singlethread)
75 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
77 --serialized)
78 SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
80 --temp)
81 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6"
83 --legacy)
84 doWal=0
85 CC_OPTS="$CC_OPTS -DSPEEDTEST_OMIT_HASH"
87 --verify)
88 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --verify"
90 --wal)
91 doWal=1
93 --size)
94 shift; SIZE=$1
96 --cachesize)
97 shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --cachesize $1"
99 --stmtcache)
100 shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtcache $1"
102 --nolongdouble)
103 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --nolongdouble"
105 --checkpoint)
106 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --checkpoint"
108 --explain)
109 doExplain=1
111 --vdbeprofile)
112 rm -f vdbe_profile.out
113 CC_OPTS="$CC_OPTS -DVDBE_PROFILE"
114 doCachegrind=0
115 doVdbeProfile=1
117 --lean)
118 CC_OPTS="$CC_OPTS $LEAN_OPTS"
120 --clang)
121 CC=clang
123 --icc)
124 CC=/home/drh/intel/bin/icc
126 --gcc7)
127 CC=gcc-7
129 --heap)
130 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
131 shift;
132 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
134 --lookaside)
135 shift;
136 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2"
137 shift;
139 --repeat)
140 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE"
141 shift;
142 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --repeat $1"
144 --mmap)
145 shift;
146 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1"
148 --rtree)
149 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
150 CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
152 --persist)
153 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --persist"
155 --orm)
156 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
158 --cte)
159 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
161 --fp)
162 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
164 --stmtscanstatus)
165 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtscanstatus"
168 CC_OPTS="$CC_OPTS $1"
171 BASELINE=$1
173 esac
174 shift
175 done
176 if test $doWal -eq 1; then
177 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
179 SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE"
180 echo "NAME = $NAME" | tee summary-$NAME.txt
181 echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt
182 echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
183 rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
184 if test $doVdbeProfile -eq 1; then
185 rm -f vdbe_profile.out
187 $CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
188 size sqlite3.o | tee -a summary-$NAME.txt
189 if test $doExplain -eq 1; then
190 $CC -g -Os -Wall -I. $CC_OPTS \
191 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
192 ./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
194 SRC=./speedtest1.c
195 $CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
196 ls -l speedtest1 | tee -a summary-$NAME.txt
197 if test $doCachegrind -eq 1; then
198 valgrind --tool=cachegrind ./speedtest1 speedtest1.db \
199 $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
200 else
201 ./speedtest1 speedtest1.db $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
203 size sqlite3.o | tee -a summary-$NAME.txt
204 wc sqlite3.c
205 if test $doCachegrind -eq 1; then
206 cg_anno.tcl cachegrind.out.* >cout-$NAME.txt
207 echo '*****************************************************' >>cout-$NAME.txt
208 sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>cout-$NAME.txt
210 if test $doExplain -eq 1; then
211 ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
213 if test $doVdbeProfile -eq 1; then
214 tclsh ../sqlite/tool/vdbe_profile.tcl >vdbeprofile-$NAME.txt
215 open vdbeprofile-$NAME.txt
217 if test "$NAME" != "$BASELINE" -a $doVdbeProfile -ne 1 -a $doDiff -ne 0; then
218 fossil test-diff --tk -c 20 cout-$BASELINE.txt cout-$NAME.txt