Add speed3.test file. For testing performance issues related to overflow pages. (CVS 4020)

FossilOrigin-Name: 684f765df3e8a4836f254717d175a4a7b5e7d15f
This commit is contained in:
danielk1977 2007-05-17 14:45:12 +00:00
parent f12737da7e
commit 63c64f3b8c
4 changed files with 182 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Modify\stest\sscripts\sto\sallow\sfor\sthe\sfact\sthat\szeroblob()\sis\snot\savailable\swhen\scompiled\swith\sOMIT_INCRBLOB.\sTicket\s#2365.\s(CVS\s4019)
D 2007-05-17T06:44:28
C Add\sspeed3.test\sfile.\sFor\stesting\sperformance\sissues\srelated\sto\soverflow\spages.\s(CVS\s4020)
D 2007-05-17T14:45:13
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -109,7 +109,7 @@ F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
F src/tclsqlite.c f425c7583665ef78dd8397b2de0b8e0028e80ce2
F src/test1.c 84c841e1088f743200b87581506e93f70344bd32
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
F src/test3.c 946ea9d1a8c928656e3c70f0a2fcb8e733a15e86
F src/test3.c a280931fb40222b7c90da45eea926459beee8904
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
F src/test5.c c40a4cf43266c1c6da7bcb737d294304a177e6cc
F src/test6.c 5957d249d437e4db74045ce2f1f661648d94bf94
@ -345,6 +345,7 @@ F test/shared_err.test cc528f6e78665787e93d9ce3a782a2ce5179d821
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
F test/speed3.test 2c1947ad95b0d5cbd41a485c62402911ef9fd541
F test/sqllimits1.test b15a5784e47199d68fa1182157ba7e790f467d9f
F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797
F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4
@ -492,7 +493,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 73e654fbdc791daa10c49557bf479f152586ac28
R c13d834540a30a1f8b30b83cb25a8ca2
P 2ee959be4afa2cf05d183ff92a31dd1b5a84becf
R da5d5d48e56670e943a5c8c37e2f8834
U danielk1977
Z 77d3bac28b115aab1826c7188efad160
Z 35759e4b823e1a75e52d456c8ba860fe

View File

@ -1 +1 @@
2ee959be4afa2cf05d183ff92a31dd1b5a84becf
684f765df3e8a4836f254717d175a4a7b5e7d15f

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test3.c,v 1.74 2007/05/02 01:34:32 drh Exp $
** $Id: test3.c,v 1.75 2007/05/17 14:45:13 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@ -1425,10 +1425,11 @@ static int btree_from_db(
Tcl_CmdInfo info;
sqlite3 *db;
Btree *pBt;
int iDb = 0;
if( argc!=2 ){
if( argc!=2 && argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB-HANDLE\"", 0);
" DB-HANDLE ?N?\"", 0);
return TCL_ERROR;
}
@ -1436,10 +1437,14 @@ static int btree_from_db(
Tcl_AppendResult(interp, "No such db-handle: \"", argv[1], "\"", 0);
return TCL_ERROR;
}
if( argc==3 ){
iDb = atoi(argv[2]);
}
db = *((sqlite3 **)info.objClientData);
assert( db );
pBt = db->aDb[0].pBt;
pBt = db->aDb[iDb].pBt;
sqlite3_snprintf(sizeof(zBuf), zBuf, "%p", pBt);
Tcl_SetResult(interp, zBuf, TCL_VOLATILE);
return TCL_OK;

165
test/speed3.test Normal file
View File

@ -0,0 +1,165 @@
# 2007 May 17
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing that the overflow-page related
# enhancements added after version 3.3.17 speed things up.
#
# $Id: speed3.test,v 1.1 2007/05/17 14:45:13 danielk1977 Exp $
#
#---------------------------------------------------------------------
# Test plan:
#
# If auto-vacuum is enabled for the database, the following cases
# should show performance improvement with respect to 3.3.17.
#
# + When deleting rows that span overflow pages. This is faster
# because the overflow pages no longer need to be read before
# they can be moved to the free list (test cases speed3-1.X).
#
# + When reading a column value stored on an overflow page that
# is not the first overflow page for the row. The improvement
# in this case is because the overflow pages between the tree
# page and the overflow page containing the value do not have
# to be read (test cases speed3-2.X).
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
speed_trial_init speed1
# Set a uniform random seed
expr srand(0)
set ::NROW 1000
# The number_name procedure below converts its argment (an integer)
# into a string which is the English-language name for that number.
#
# Example:
#
# puts [number_name 123] -> "one hundred twenty three"
#
set ones {zero one two three four five six seven eight nine
ten eleven twelve thirteen fourteen fifteen sixteen seventeen
eighteen nineteen}
set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
proc number_name {n} {
if {$n>=1000} {
set txt "[number_name [expr {$n/1000}]] thousand"
set n [expr {$n%1000}]
} else {
set txt {}
}
if {$n>=100} {
append txt " [lindex $::ones [expr {$n/100}]] hundred"
set n [expr {$n%100}]
}
if {$n>=20} {
append txt " [lindex $::tens [expr {$n/10}]]"
set n [expr {$n%10}]
}
if {$n>0} {
append txt " [lindex $::ones $n]"
}
set txt [string trim $txt]
if {$txt==""} {set txt zero}
return $txt
}
proc populate_t1 {db} {
$db transaction {
for {set ii 0} {$ii < $::NROW} {incr ii} {
set N [number_name $ii]
set repeats [expr {(10000/[string length $N])+1}]
set text [string range [string repeat $N $repeats] 0 10000]
$db eval {INSERT INTO main.t1 VALUES($ii, $text, $ii)}
}
$db eval {INSERT INTO aux.t1 SELECT * FROM main.t1}
}
}
proc io_log {db} {
array set stats1 [btree_pager_stats [btree_from_db db]]
array set stats2 [btree_pager_stats [btree_from_db db 2]]
# puts "1: [array get stats1]"
# puts "2: [array get stats2]"
puts "Incrvacuum: Read $stats1(read), wrote $stats1(write)"
puts "Normal : Read $stats2(read), wrote $stats2(write)"
}
proc reset_db {} {
db close
sqlite3 db test.db
db eval {
PRAGMA main.cache_size = 200000;
PRAGMA main.auto_vacuum = 'incremental';
ATTACH 'test2.db' AS 'aux';
PRAGMA aux.auto_vacuum = 'none';
}
}
file delete -force test2.db test2.db-journal
reset_db
# Set up a database in auto-vacuum mode and create a database schema.
#
do_test speed3-0.1 {
execsql {
CREATE TABLE main.t1(a INTEGER, b TEXT, c INTEGER);
}
execsql {
SELECT name FROM sqlite_master ORDER BY 1;
}
} {t1}
do_test speed3-0.2 {
execsql {
CREATE TABLE aux.t1(a INTEGER, b TEXT, c INTEGER);
}
execsql {
SELECT name FROM aux.sqlite_master ORDER BY 1;
}
} {t1}
do_test speed3-0.3 {
populate_t1 db
execsql {
SELECT count(*) FROM main.t1;
SELECT count(*) FROM aux.t1;
}
} "$::NROW $::NROW"
do_test speed3-0.4 {
execsql {
PRAGMA main.auto_vacuum;
PRAGMA aux.auto_vacuum;
}
} {2 0}
# Delete all content in a table, one row at a time.
#
#io_log db
reset_db
speed_trial speed3-1.incrvacuum $::NROW row {DELETE FROM main.t1 WHERE 1}
speed_trial speed3-1.normal $::NROW row {DELETE FROM aux.t1 WHERE 1}
io_log db
# Select the "C" column (located at the far end of the overflow
# chain) from each table row.
#
db eval {PRAGMA incremental_vacuum(500000)}
populate_t1 db
reset_db
speed_trial speed3-2.incrvacuum $::NROW row {SELECT c FROM main.t1}
speed_trial speed3-2.normal $::NROW row {SELECT c FROM aux.t1}
io_log db
finish_test