drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # This is a template for a script used for day-to-day size and |
| 4 | # performance monitoring of SQLite. Typical usage: |
| 5 | # |
| 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 |
| 9 | # |
| 10 | # There are multiple output files, all with a base name given by |
| 11 | # the first argument: |
| 12 | # |
| 13 | # summary-$BASE.txt # Copy of standard output |
| 14 | # cout-$BASE.txt # cachegrind output |
| 15 | # explain-$BASE.txt # EXPLAIN listings (only with --explain) |
| 16 | # |
| 17 | if test "$1" = "" |
| 18 | then |
| 19 | echo "Usage: $0 OUTPUTFILE [OPTIONS]" |
| 20 | exit |
| 21 | fi |
| 22 | NAME=$1 |
| 23 | shift |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 24 | #CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5" |
| 25 | CC_OPTS="-DSQLITE_ENABLE_MEMSYS5" |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 26 | CC=gcc |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 27 | SPEEDTEST_OPTS="--shrink-memory --reprepare --stats --heap 10000000 64" |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 28 | SIZE=5 |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 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" |
drh | ff0a67a | 2017-10-11 12:20:36 +0000 | [diff] [blame] | 32 | LEAN_OPTS="$LEAN_OPTS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS" |
drh | 87f0e98 | 2016-09-24 01:41:59 +0000 | [diff] [blame] | 33 | LEAN_OPTS="$LEAN_OPTS -DSQLITE_MAX_EXPR_DEPTH=0" |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 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" |
drh | 1a7df58 | 2016-10-01 23:55:23 +0000 | [diff] [blame] | 38 | LEAN_OPTS="$LEAN_OPTS -DSQLITE_USE_ALLOCA" |
drh | ff0a67a | 2017-10-11 12:20:36 +0000 | [diff] [blame] | 39 | BASELINE="trunk" |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 40 | doExplain=0 |
| 41 | doCachegrind=1 |
| 42 | while test "$1" != ""; do |
| 43 | case $1 in |
| 44 | --reprepare) |
| 45 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 46 | ;; |
| 47 | --autovacuum) |
| 48 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 49 | ;; |
| 50 | --utf16be) |
| 51 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 52 | ;; |
| 53 | --stats) |
| 54 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 55 | ;; |
| 56 | --without-rowid) |
| 57 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 58 | ;; |
| 59 | --nomemstat) |
| 60 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" |
| 61 | ;; |
| 62 | --temp) |
| 63 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6" |
| 64 | ;; |
| 65 | --wal) |
| 66 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal" |
| 67 | ;; |
| 68 | --size) |
| 69 | shift; SIZE=$1 |
| 70 | ;; |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 71 | --cachesize) |
| 72 | shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --cachesize $1" |
| 73 | ;; |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 74 | --explain) |
| 75 | doExplain=1 |
| 76 | ;; |
| 77 | --vdbeprofile) |
| 78 | rm -f vdbe_profile.out |
| 79 | CC_OPTS="$CC_OPTS -DVDBE_PROFILE" |
| 80 | doCachegrind=0 |
| 81 | ;; |
drh | 98ef26b | 2016-09-21 23:58:49 +0000 | [diff] [blame] | 82 | --lean) |
| 83 | CC_OPTS="$CC_OPTS $LEAN_OPTS" |
| 84 | ;; |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 85 | --clang) |
| 86 | CC=clang |
| 87 | ;; |
drh | 2aa3133 | 2017-07-08 22:30:30 +0000 | [diff] [blame] | 88 | --icc) |
| 89 | CC=/home/drh/intel/bin/icc |
| 90 | ;; |
| 91 | --gcc7) |
| 92 | CC=gcc-7 |
| 93 | ;; |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 94 | --heap) |
| 95 | CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5" |
| 96 | shift; |
| 97 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64" |
| 98 | ;; |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 99 | --lookaside) |
| 100 | shift; |
| 101 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2" |
| 102 | shift; |
| 103 | ;; |
drh | f8a89ca | 2016-10-18 14:35:55 +0000 | [diff] [blame] | 104 | --repeat) |
| 105 | CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE" |
| 106 | shift; |
| 107 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --repeat $1" |
| 108 | ;; |
drh | 26f4198 | 2016-12-12 23:24:08 +0000 | [diff] [blame] | 109 | --mmap) |
| 110 | shift; |
| 111 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1" |
| 112 | ;; |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 113 | --rtree) |
| 114 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree" |
| 115 | CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE" |
| 116 | ;; |
drh | 2aa3133 | 2017-07-08 22:30:30 +0000 | [diff] [blame] | 117 | --orm) |
| 118 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm" |
| 119 | ;; |
dan | f6c37db | 2017-12-26 14:30:44 +0000 | [diff] [blame] | 120 | --cte) |
| 121 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte" |
| 122 | ;; |
| 123 | --fp) |
| 124 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp" |
| 125 | ;; |
drh | ff0a67a | 2017-10-11 12:20:36 +0000 | [diff] [blame] | 126 | -*) |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 127 | CC_OPTS="$CC_OPTS $1" |
| 128 | ;; |
drh | ff0a67a | 2017-10-11 12:20:36 +0000 | [diff] [blame] | 129 | *) |
| 130 | BASELINE=$1 |
| 131 | ;; |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 132 | esac |
| 133 | shift |
| 134 | done |
| 135 | SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE" |
| 136 | echo "NAME = $NAME" | tee summary-$NAME.txt |
| 137 | echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt |
| 138 | echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt |
| 139 | rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 140 | $CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 141 | size sqlite3.o | tee -a summary-$NAME.txt |
| 142 | if test $doExplain -eq 1; then |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 143 | $CC -g -Os -Wall -I. $CC_OPTS \ |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 144 | -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ |
| 145 | ./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread |
| 146 | fi |
| 147 | SRC=./speedtest1.c |
drh | 5082867 | 2017-01-20 16:09:12 +0000 | [diff] [blame] | 148 | $CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 149 | ls -l speedtest1 | tee -a summary-$NAME.txt |
| 150 | if test $doCachegrind -eq 1; then |
| 151 | valgrind --tool=cachegrind ./speedtest1 speedtest1.db \ |
| 152 | $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt |
| 153 | else |
| 154 | ./speedtest1 speedtest1.db $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt |
| 155 | fi |
| 156 | size sqlite3.o | tee -a summary-$NAME.txt |
| 157 | wc sqlite3.c |
| 158 | if test $doCachegrind -eq 1; then |
| 159 | cg_anno.tcl cachegrind.out.* >cout-$NAME.txt |
drh | dccf4f2 | 2017-08-12 02:16:34 +0000 | [diff] [blame] | 160 | echo '*****************************************************' >>cout-$NAME.txt |
| 161 | sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>cout-$NAME.txt |
drh | ed90a46 | 2016-05-21 00:45:54 +0000 | [diff] [blame] | 162 | fi |
| 163 | if test $doExplain -eq 1; then |
| 164 | ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt |
| 165 | fi |
drh | ff0a67a | 2017-10-11 12:20:36 +0000 | [diff] [blame] | 166 | if test "$NAME" != "$BASELINE"; then |
| 167 | fossil test-diff --tk -c 20 cout-$BASELINE.txt cout-$NAME.txt |
drh | 27c8467 | 2017-01-28 13:40:55 +0000 | [diff] [blame] | 168 | fi |