run-speed-test.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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
  24. CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5"
  25. SPEEDTEST_OPTS="--shrink-memory --reprepare --heap 10000000 64"
  26. SIZE=5
  27. doExplain=0
  28. while test "$1" != ""; do
  29. case $1 in
  30. --reprepare)
  31. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  32. ;;
  33. --autovacuum)
  34. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  35. ;;
  36. --utf16be)
  37. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  38. ;;
  39. --stats)
  40. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  41. ;;
  42. --without-rowid)
  43. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  44. ;;
  45. --nomemstat)
  46. SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1"
  47. ;;
  48. --wal)
  49. SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal"
  50. ;;
  51. --size)
  52. shift; SIZE=$1
  53. ;;
  54. --explain)
  55. doExplain=1
  56. ;;
  57. --heap)
  58. CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5"
  59. shift;
  60. SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64"
  61. ;;
  62. *)
  63. CC_OPTS="$CC_OPTS $1"
  64. ;;
  65. esac
  66. shift
  67. done
  68. SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE"
  69. echo "NAME = $NAME" | tee summary-$NAME.txt
  70. echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt
  71. echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt
  72. rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o
  73. gcc -g -Os -Wall -I. $CC_OPTS -c sqlite3.c
  74. size sqlite3.o | tee -a summary-$NAME.txt
  75. if test $doExplain -eq 1; then
  76. gcc -g -Os -Wall -I. $CC_OPTS \
  77. -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
  78. ./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread
  79. fi
  80. SRC=./speedtest1.c
  81. gcc -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread
  82. ls -l speedtest1 | tee -a summary-$NAME.txt
  83. valgrind --tool=cachegrind ./speedtest1 speedtest1.db \
  84. $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt
  85. size sqlite3.o | tee -a summary-$NAME.txt
  86. wc sqlite3.c
  87. cg_anno.tcl cachegrind.out.* >cout-$NAME.txt
  88. if test $doExplain -eq 1; then
  89. ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt
  90. fi