2016-05-21 02:45:54 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This is a template for a script used for day-to-day size and
|
|
|
|
# performance monitoring of SQLite. Typical usage:
|
|
|
|
#
|
2022-11-07 18:21:53 +01:00
|
|
|
# sh speed-check.sh trunk # Baseline measurement of trunk
|
|
|
|
# sh speed-check.sh x1 # Measure some experimental change
|
|
|
|
# fossil xdiff --tk cout-trunk.txt cout-x1.txt # View chanages
|
2016-05-21 02:45:54 +02:00
|
|
|
#
|
|
|
|
# There are multiple output files, all with a base name given by
|
|
|
|
# the first argument:
|
|
|
|
#
|
|
|
|
# summary-$BASE.txt # Copy of standard output
|
|
|
|
# cout-$BASE.txt # cachegrind output
|
|
|
|
# explain-$BASE.txt # EXPLAIN listings (only with --explain)
|
|
|
|
#
|
|
|
|
if test "$1" = ""
|
|
|
|
then
|
|
|
|
echo "Usage: $0 OUTPUTFILE [OPTIONS]"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
NAME=$1
|
|
|
|
shift
|
2016-09-22 01:58:49 +02:00
|
|
|
#CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
|
|
|
|
CC_OPTS="-DSQLITE_ENABLE_MEMSYS5"
|
2017-01-20 17:09:12 +01:00
|
|
|
CC=gcc
|
2016-09-22 01:58:49 +02:00
|
|
|
SPEEDTEST_OPTS="--shrink-memory --reprepare --stats --heap 10000000 64"
|
2016-05-21 02:45:54 +02:00
|
|
|
SIZE=5
|
2016-09-22 01:58:49 +02:00
|
|
|
LEAN_OPTS="-DSQLITE_THREADSAFE=0"
|
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_DEFAULT_MEMSTATUS=0"
|
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1"
|
2017-10-11 14:20:36 +02:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS"
|
2016-09-24 03:41:59 +02:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_MAX_EXPR_DEPTH=0"
|
2016-09-22 01:58:49 +02:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_DECLTYPE"
|
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_DEPRECATED"
|
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_PROGRESS_CALLBACK"
|
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_SHARED_CACHE"
|
2016-10-02 01:55:23 +02:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_USE_ALLOCA"
|
2017-10-11 14:20:36 +02:00
|
|
|
BASELINE="trunk"
|
2016-05-21 02:45:54 +02:00
|
|
|
doExplain=0
|
|
|
|
doCachegrind=1
|
2018-02-12 21:50:28 +01:00
|
|
|
doVdbeProfile=0
|
2018-02-20 18:02:31 +01:00
|
|
|
doWal=1
|
2018-05-24 18:18:35 +02:00
|
|
|
doDiff=1
|
2016-05-21 02:45:54 +02:00
|
|
|
while test "$1" != ""; do
|
|
|
|
case $1 in
|
2018-05-24 18:18:35 +02:00
|
|
|
--nodiff)
|
|
|
|
doDiff=0
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--reprepare)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--autovacuum)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--utf16be)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--stats)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--without-rowid)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2021-11-03 13:50:28 +01:00
|
|
|
--strict)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--nomemstat)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2019-09-21 15:34:59 +02:00
|
|
|
--multithread)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--singlethread)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--serialized)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--temp)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6"
|
|
|
|
;;
|
2018-02-20 18:02:31 +01:00
|
|
|
--legacy)
|
|
|
|
doWal=0
|
2020-06-26 16:05:58 +02:00
|
|
|
CC_OPTS="$CC_OPTS -DSPEEDTEST_OMIT_HASH"
|
|
|
|
;;
|
|
|
|
--verify)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --verify"
|
2018-02-20 18:02:31 +01:00
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--wal)
|
2018-02-20 18:02:31 +01:00
|
|
|
doWal=1
|
2016-05-21 02:45:54 +02:00
|
|
|
;;
|
|
|
|
--size)
|
|
|
|
shift; SIZE=$1
|
|
|
|
;;
|
2016-09-22 01:58:49 +02:00
|
|
|
--cachesize)
|
|
|
|
shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --cachesize $1"
|
|
|
|
;;
|
2022-09-12 18:07:24 +02:00
|
|
|
--stmtcache)
|
|
|
|
shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtcache $1"
|
|
|
|
;;
|
2020-08-07 16:47:55 +02:00
|
|
|
--checkpoint)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --checkpoint"
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--explain)
|
|
|
|
doExplain=1
|
|
|
|
;;
|
|
|
|
--vdbeprofile)
|
|
|
|
rm -f vdbe_profile.out
|
|
|
|
CC_OPTS="$CC_OPTS -DVDBE_PROFILE"
|
|
|
|
doCachegrind=0
|
2018-02-12 21:50:28 +01:00
|
|
|
doVdbeProfile=1
|
2016-05-21 02:45:54 +02:00
|
|
|
;;
|
2016-09-22 01:58:49 +02:00
|
|
|
--lean)
|
|
|
|
CC_OPTS="$CC_OPTS $LEAN_OPTS"
|
|
|
|
;;
|
2017-01-20 17:09:12 +01:00
|
|
|
--clang)
|
|
|
|
CC=clang
|
|
|
|
;;
|
2017-07-09 00:30:30 +02:00
|
|
|
--icc)
|
|
|
|
CC=/home/drh/intel/bin/icc
|
|
|
|
;;
|
|
|
|
--gcc7)
|
|
|
|
CC=gcc-7
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
--heap)
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
|
|
|
|
;;
|
2017-01-20 17:09:12 +01:00
|
|
|
--lookaside)
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2"
|
|
|
|
shift;
|
|
|
|
;;
|
2016-10-18 16:35:55 +02:00
|
|
|
--repeat)
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE"
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --repeat $1"
|
|
|
|
;;
|
2016-12-13 00:24:08 +01:00
|
|
|
--mmap)
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1"
|
|
|
|
;;
|
2017-01-20 17:09:12 +01:00
|
|
|
--rtree)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
|
|
|
|
;;
|
2022-09-12 18:07:24 +02:00
|
|
|
--persist)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --persist"
|
|
|
|
;;
|
2017-07-09 00:30:30 +02:00
|
|
|
--orm)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
|
|
|
|
;;
|
2017-12-26 15:30:44 +01:00
|
|
|
--cte)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
|
|
|
|
;;
|
|
|
|
--fp)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
|
|
|
|
;;
|
2024-01-20 17:18:04 +01:00
|
|
|
--parsenumber)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset parsenumber"
|
|
|
|
;;
|
2023-02-28 21:06:30 +01:00
|
|
|
--stmtscanstatus)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtscanstatus"
|
|
|
|
;;
|
2017-10-11 14:20:36 +02:00
|
|
|
-*)
|
2016-05-21 02:45:54 +02:00
|
|
|
CC_OPTS="$CC_OPTS $1"
|
|
|
|
;;
|
2017-10-11 14:20:36 +02:00
|
|
|
*)
|
|
|
|
BASELINE=$1
|
|
|
|
;;
|
2016-05-21 02:45:54 +02:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2018-02-20 18:02:31 +01:00
|
|
|
if test $doWal -eq 1; then
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
|
|
|
|
fi
|
2016-05-21 02:45:54 +02:00
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE"
|
|
|
|
echo "NAME = $NAME" | tee summary-$NAME.txt
|
|
|
|
echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt
|
|
|
|
echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
|
|
|
|
rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
|
2018-02-12 21:50:28 +01:00
|
|
|
if test $doVdbeProfile -eq 1; then
|
|
|
|
rm -f vdbe_profile.out
|
|
|
|
fi
|
2017-01-20 17:09:12 +01:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
|
2016-05-21 02:45:54 +02:00
|
|
|
size sqlite3.o | tee -a summary-$NAME.txt
|
|
|
|
if test $doExplain -eq 1; then
|
2017-01-20 17:09:12 +01:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS \
|
2016-05-21 02:45:54 +02:00
|
|
|
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
|
|
|
|
./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
|
|
|
|
fi
|
|
|
|
SRC=./speedtest1.c
|
2017-01-20 17:09:12 +01:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
|
2016-05-21 02:45:54 +02:00
|
|
|
ls -l speedtest1 | tee -a summary-$NAME.txt
|
|
|
|
if test $doCachegrind -eq 1; then
|
|
|
|
valgrind --tool=cachegrind ./speedtest1 speedtest1.db \
|
|
|
|
$SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
|
|
|
|
else
|
|
|
|
./speedtest1 speedtest1.db $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
|
|
|
|
fi
|
|
|
|
size sqlite3.o | tee -a summary-$NAME.txt
|
|
|
|
wc sqlite3.c
|
|
|
|
if test $doCachegrind -eq 1; then
|
|
|
|
cg_anno.tcl cachegrind.out.* >cout-$NAME.txt
|
2017-08-12 04:16:34 +02:00
|
|
|
echo '*****************************************************' >>cout-$NAME.txt
|
|
|
|
sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>cout-$NAME.txt
|
2016-05-21 02:45:54 +02:00
|
|
|
fi
|
|
|
|
if test $doExplain -eq 1; then
|
|
|
|
./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
|
|
|
|
fi
|
2018-02-12 21:50:28 +01:00
|
|
|
if test $doVdbeProfile -eq 1; then
|
|
|
|
tclsh ../sqlite/tool/vdbe_profile.tcl >vdbeprofile-$NAME.txt
|
|
|
|
open vdbeprofile-$NAME.txt
|
|
|
|
fi
|
2018-05-24 18:18:35 +02:00
|
|
|
if test "$NAME" != "$BASELINE" -a $doVdbeProfile -ne 1 -a $doDiff -ne 0; then
|
2017-10-11 14:20:36 +02:00
|
|
|
fossil test-diff --tk -c 20 cout-$BASELINE.txt cout-$NAME.txt
|
2017-01-28 14:40:55 +01:00
|
|
|
fi
|