Update speedtest1.c with new testset "trigger" based on the tests in

speed4p.test.

FossilOrigin-Name: 7b7fa5fa0dd0dcef759ce1e22ade3a4e5fc8e8a244eac19b1abcc96d89c99721
This commit is contained in:
dan 2018-04-03 20:00:09 +00:00
parent 22f60b847c
commit b278c594f1
3 changed files with 210 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\sfew\ssmall\stest\sscript\sissues\saffecting\sSQLITE_TEMP_STORE=3\sbuilds.
D 2018-04-03T17:05:13.814
C Update\sspeedtest1.c\swith\snew\stestset\s"trigger"\sbased\son\sthe\stests\sin\nspeed4p.test.
D 2018-04-03T20:00:09.543
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 7016fc56c6b9bfe5daac4f34be8be38d8c0b5fab79ccbfb764d3b23bf1c6fff3
@ -1271,7 +1271,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c
F test/speedtest1.c a5faf4cbe5769eee4b721b3875cb3f12520a9b99d9026b1063b47c39603375b8
F test/speedtest1.c 3f17427600e858bcdaa0eb3075c1a2921c02db6d35a176c24a9dcd9b13d20812
F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e
F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
@ -1717,7 +1717,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 3328e828e28ca7198fd1ce84503e649ab2278913a2cf85a0f0391f31d0c9c8d7
R c600f0dbbfcdccc3c37d773350506968
P e171f3722f78c58d2f20443e3bbcce2bd9701b8537f6e8d482ae804154d7a17f
R e402f9a2982145c160d4e44decc8af99
U dan
Z 3446c82a2fe0b428ce0106172b072bb3
Z 88086f03d47fff48f3d9b964051d594b

View File

@ -1 +1 @@
e171f3722f78c58d2f20443e3bbcce2bd9701b8537f6e8d482ae804154d7a17f
7b7fa5fa0dd0dcef759ce1e22ade3a4e5fc8e8a244eac19b1abcc96d89c99721

View File

@ -1645,6 +1645,207 @@ void testset_orm(void){
speedtest1_end_test();
}
/*
*/
void testset_trigger(void){
int jj, ii;
char zNum[2000]; /* A number name */
const int NROW = 50000;
const int NROW2 = 10000;
speedtest1_exec(
"BEGIN;"
"CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
"CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
"CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
"CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;"
"CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;"
"CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;"
);
for(jj=1; jj<=3; jj++){
speedtest1_prepare("INSERT INTO t%d VALUES(NULL,?1,?2)", jj);
for(ii=0; ii<NROW; ii++){
int x1 = speedtest1_random() % NROW;
speedtest1_numbername(x1, zNum, sizeof(zNum));
sqlite3_bind_int(g.pStmt, 1, x1);
sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
speedtest1_run();
}
}
speedtest1_exec(
"CREATE INDEX i1 ON t1(t);"
"CREATE INDEX i2 ON t2(t);"
"CREATE INDEX i3 ON t3(t);"
"COMMIT;"
);
speedtest1_begin_test(100, "speed4p-join1");
speedtest1_prepare(
"SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
);
speedtest1_run();
speedtest1_end_test();
speedtest1_begin_test(110, "speed4p-join2");
speedtest1_prepare(
"SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
);
speedtest1_run();
speedtest1_end_test();
speedtest1_begin_test(120, "speed4p-view1");
for(jj=1; jj<=3; jj++){
speedtest1_prepare("SELECT * FROM v%d WHERE rowid = ?", jj);
for(ii=0; ii<NROW2; ii+=3){
sqlite3_bind_int(g.pStmt, 1, ii*3);
speedtest1_run();
}
}
speedtest1_end_test();
speedtest1_begin_test(130, "speed4p-table1");
for(jj=1; jj<=3; jj++){
speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj);
for(ii=0; ii<NROW2; ii+=3){
sqlite3_bind_int(g.pStmt, 1, ii*3);
speedtest1_run();
}
}
speedtest1_end_test();
speedtest1_begin_test(140, "speed4p-table1");
for(jj=1; jj<=3; jj++){
speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj);
for(ii=0; ii<NROW2; ii+=3){
sqlite3_bind_int(g.pStmt, 1, ii*3);
speedtest1_run();
}
}
speedtest1_end_test();
speedtest1_begin_test(150, "speed4p-subselect1");
speedtest1_prepare("SELECT "
"(SELECT t FROM t1 WHERE rowid = ?1),"
"(SELECT t FROM t2 WHERE rowid = ?1),"
"(SELECT t FROM t3 WHERE rowid = ?1)"
);
for(jj=0; jj<NROW2; jj++){
sqlite3_bind_int(g.pStmt, 1, jj*3);
speedtest1_run();
}
speedtest1_end_test();
speedtest1_begin_test(160, "speed4p-rowid-update");
speedtest1_exec("BEGIN");
speedtest1_prepare("UPDATE t1 SET i=i+1 WHERE rowid=?1");
for(jj=0; jj<NROW2; jj++){
sqlite3_bind_int(g.pStmt, 1, jj);
speedtest1_run();
}
speedtest1_exec("COMMIT");
speedtest1_end_test();
speedtest1_exec("CREATE TABLE t5(t TEXT PRIMARY KEY, i INTEGER);");
speedtest1_begin_test(170, "speed4p-insert-ignore");
speedtest1_exec("INSERT OR IGNORE INTO t5 SELECT t, i FROM t1");
speedtest1_end_test();
speedtest1_exec(
"CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);"
"CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
"CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN"
" INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);"
"END;"
"CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN"
" INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);"
"END;"
"CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN"
" INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);"
"END;"
"BEGIN;"
);
speedtest1_begin_test(180, "speed4p-trigger1");
speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
for(jj=0; jj<NROW2; jj++){
speedtest1_numbername(jj, zNum, sizeof(zNum));
sqlite3_bind_int(g.pStmt, 1, jj);
sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
speedtest1_run();
}
speedtest1_end_test();
/*
** Note: Of the queries, only half actually update a row. This property
** was copied over from speed4p.test, where it was probably introduced
** inadvertantly.
*/
speedtest1_begin_test(190, "speed4p-trigger2");
speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
for(jj=1; jj<=NROW2*2; jj+=2){
speedtest1_numbername(jj*2, zNum, sizeof(zNum));
sqlite3_bind_int(g.pStmt, 1, jj*2);
sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
sqlite3_bind_int(g.pStmt, 3, jj);
speedtest1_run();
}
speedtest1_end_test();
/*
** Note: Same again.
*/
speedtest1_begin_test(200, "speed4p-trigger3");
speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
for(jj=1; jj<=NROW2*2; jj+=2){
sqlite3_bind_int(g.pStmt, 1, jj*2);
speedtest1_run();
}
speedtest1_end_test();
speedtest1_exec("COMMIT");
/*
** The following block contains the same tests as the above block that
** tests triggers, with one crucial difference: no triggers are defined.
** So the difference in speed between these tests and the preceding ones
** is the amount of time taken to compile and execute the trigger programs.
*/
speedtest1_exec(
"DROP TABLE t4;"
"DROP TABLE log;"
"VACUUM;"
"CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
"BEGIN;"
);
speedtest1_begin_test(210, "speed4p-notrigger1");
speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
for(jj=0; jj<NROW2; jj++){
speedtest1_numbername(jj, zNum, sizeof(zNum));
sqlite3_bind_int(g.pStmt, 1, jj);
sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
speedtest1_run();
}
speedtest1_end_test();
speedtest1_begin_test(210, "speed4p-notrigger2");
speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
for(jj=1; jj<=NROW2*2; jj+=2){
speedtest1_numbername(jj*2, zNum, sizeof(zNum));
sqlite3_bind_int(g.pStmt, 1, jj*2);
sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
sqlite3_bind_int(g.pStmt, 3, jj);
speedtest1_run();
}
speedtest1_end_test();
speedtest1_begin_test(220, "speed4p-notrigger3");
speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
for(jj=1; jj<=NROW2*2; jj+=2){
sqlite3_bind_int(g.pStmt, 1, jj*2);
speedtest1_run();
}
speedtest1_end_test();
speedtest1_exec("COMMIT");
}
/*
** A testset used for debugging speedtest1 itself.
*/
@ -1945,6 +2146,8 @@ int main(int argc, char **argv){
testset_cte();
}else if( strcmp(zTSet,"fp")==0 ){
testset_fp();
}else if( strcmp(zTSet,"trigger")==0 ){
testset_trigger();
}else if( strcmp(zTSet,"rtree")==0 ){
#ifdef SQLITE_ENABLE_RTREE
testset_rtree(6, 147);