2016-05-21 03:45:54 +03:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This is a template for a script used for day-to-day size and
|
|
|
|
# performance monitoring of SQLite. Typical usage:
|
|
|
|
#
|
|
|
|
# sh run-speed-test.sh trunk # Baseline measurement of trunk
|
|
|
|
# sh run-speed-test.sh x1 # Measure some experimental change
|
|
|
|
# fossil test-diff --tk cout-trunk.txt cout-x1.txt # View chanages
|
|
|
|
#
|
|
|
|
# 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 02:58:49 +03:00
|
|
|
#CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
|
|
|
|
CC_OPTS="-DSQLITE_ENABLE_MEMSYS5"
|
2017-01-20 19:09:12 +03:00
|
|
|
CC=gcc
|
2016-09-22 02:58:49 +03:00
|
|
|
SPEEDTEST_OPTS="--shrink-memory --reprepare --stats --heap 10000000 64"
|
2016-05-21 03:45:54 +03:00
|
|
|
SIZE=5
|
2016-09-22 02:58:49 +03: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 15:20:36 +03:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS"
|
2016-09-24 04:41:59 +03:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_MAX_EXPR_DEPTH=0"
|
2016-09-22 02:58:49 +03: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 02:55:23 +03:00
|
|
|
LEAN_OPTS="$LEAN_OPTS -DSQLITE_USE_ALLOCA"
|
2017-10-11 15:20:36 +03:00
|
|
|
BASELINE="trunk"
|
2016-05-21 03:45:54 +03:00
|
|
|
doExplain=0
|
|
|
|
doCachegrind=1
|
2018-02-12 23:50:28 +03:00
|
|
|
doVdbeProfile=0
|
2018-02-20 20:02:31 +03:00
|
|
|
doWal=1
|
2018-05-24 19:18:35 +03:00
|
|
|
doDiff=1
|
2016-05-21 03:45:54 +03:00
|
|
|
while test "$1" != ""; do
|
|
|
|
case $1 in
|
2018-05-24 19:18:35 +03:00
|
|
|
--nodiff)
|
|
|
|
doDiff=0
|
|
|
|
;;
|
2016-05-21 03:45:54 +03: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"
|
|
|
|
;;
|
|
|
|
--nomemstat)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2019-09-21 16:34:59 +03:00
|
|
|
--multithread)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--singlethread)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
|
|
|
--serialized)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
|
|
|
|
;;
|
2016-05-21 03:45:54 +03:00
|
|
|
--temp)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6"
|
|
|
|
;;
|
2018-02-20 20:02:31 +03:00
|
|
|
--legacy)
|
|
|
|
doWal=0
|
2020-06-26 17:05:58 +03:00
|
|
|
CC_OPTS="$CC_OPTS -DSPEEDTEST_OMIT_HASH"
|
|
|
|
;;
|
|
|
|
--verify)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --verify"
|
2018-02-20 20:02:31 +03:00
|
|
|
;;
|
2016-05-21 03:45:54 +03:00
|
|
|
--wal)
|
2018-02-20 20:02:31 +03:00
|
|
|
doWal=1
|
2016-05-21 03:45:54 +03:00
|
|
|
;;
|
|
|
|
--size)
|
|
|
|
shift; SIZE=$1
|
|
|
|
;;
|
2016-09-22 02:58:49 +03:00
|
|
|
--cachesize)
|
|
|
|
shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --cachesize $1"
|
|
|
|
;;
|
2020-08-07 17:47:55 +03:00
|
|
|
--checkpoint)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --checkpoint"
|
|
|
|
;;
|
2016-05-21 03:45:54 +03:00
|
|
|
--explain)
|
|
|
|
doExplain=1
|
|
|
|
;;
|
|
|
|
--vdbeprofile)
|
|
|
|
rm -f vdbe_profile.out
|
|
|
|
CC_OPTS="$CC_OPTS -DVDBE_PROFILE"
|
|
|
|
doCachegrind=0
|
2018-02-12 23:50:28 +03:00
|
|
|
doVdbeProfile=1
|
2016-05-21 03:45:54 +03:00
|
|
|
;;
|
2016-09-22 02:58:49 +03:00
|
|
|
--lean)
|
|
|
|
CC_OPTS="$CC_OPTS $LEAN_OPTS"
|
|
|
|
;;
|
2017-01-20 19:09:12 +03:00
|
|
|
--clang)
|
|
|
|
CC=clang
|
|
|
|
;;
|
2017-07-09 01:30:30 +03:00
|
|
|
--icc)
|
|
|
|
CC=/home/drh/intel/bin/icc
|
|
|
|
;;
|
|
|
|
--gcc7)
|
|
|
|
CC=gcc-7
|
|
|
|
;;
|
2016-05-21 03:45:54 +03:00
|
|
|
--heap)
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
|
|
|
|
;;
|
2017-01-20 19:09:12 +03:00
|
|
|
--lookaside)
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --lookaside $1 $2"
|
|
|
|
shift;
|
|
|
|
;;
|
2016-10-18 17:35:55 +03:00
|
|
|
--repeat)
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RCACHE"
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --repeat $1"
|
|
|
|
;;
|
2016-12-13 02:24:08 +03:00
|
|
|
--mmap)
|
|
|
|
shift;
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --mmap $1"
|
|
|
|
;;
|
2017-01-20 19:09:12 +03:00
|
|
|
--rtree)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
|
|
|
|
CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
|
|
|
|
;;
|
2017-07-09 01:30:30 +03:00
|
|
|
--orm)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
|
|
|
|
;;
|
2017-12-26 17:30:44 +03:00
|
|
|
--cte)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
|
|
|
|
;;
|
|
|
|
--fp)
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
|
|
|
|
;;
|
2017-10-11 15:20:36 +03:00
|
|
|
-*)
|
2016-05-21 03:45:54 +03:00
|
|
|
CC_OPTS="$CC_OPTS $1"
|
|
|
|
;;
|
2017-10-11 15:20:36 +03:00
|
|
|
*)
|
|
|
|
BASELINE=$1
|
|
|
|
;;
|
2016-05-21 03:45:54 +03:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2018-02-20 20:02:31 +03:00
|
|
|
if test $doWal -eq 1; then
|
|
|
|
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
|
|
|
|
fi
|
2016-05-21 03:45:54 +03: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 23:50:28 +03:00
|
|
|
if test $doVdbeProfile -eq 1; then
|
|
|
|
rm -f vdbe_profile.out
|
|
|
|
fi
|
2017-01-20 19:09:12 +03:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
|
2016-05-21 03:45:54 +03:00
|
|
|
size sqlite3.o | tee -a summary-$NAME.txt
|
|
|
|
if test $doExplain -eq 1; then
|
2017-01-20 19:09:12 +03:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS \
|
2016-05-21 03:45:54 +03:00
|
|
|
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
|
|
|
|
./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
|
|
|
|
fi
|
|
|
|
SRC=./speedtest1.c
|
2017-01-20 19:09:12 +03:00
|
|
|
$CC -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
|
2016-05-21 03:45:54 +03: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 05:16:34 +03:00
|
|
|
echo '*****************************************************' >>cout-$NAME.txt
|
|
|
|
sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>cout-$NAME.txt
|
2016-05-21 03:45:54 +03:00
|
|
|
fi
|
|
|
|
if test $doExplain -eq 1; then
|
|
|
|
./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
|
|
|
|
fi
|
2018-02-12 23:50:28 +03:00
|
|
|
if test $doVdbeProfile -eq 1; then
|
|
|
|
tclsh ../sqlite/tool/vdbe_profile.tcl >vdbeprofile-$NAME.txt
|
|
|
|
open vdbeprofile-$NAME.txt
|
|
|
|
fi
|
2018-05-24 19:18:35 +03:00
|
|
|
if test "$NAME" != "$BASELINE" -a $doVdbeProfile -ne 1 -a $doDiff -ne 0; then
|
2017-10-11 15:20:36 +03:00
|
|
|
fossil test-diff --tk -c 20 cout-$BASELINE.txt cout-$NAME.txt
|
2017-01-28 16:40:55 +03:00
|
|
|
fi
|