Add a new "testset" to the speedtest1 program: The sudoku solver.
FossilOrigin-Name: 4677ef2f8a726573c48ee2e532c00a68308dd7e1
This commit is contained in:
parent
5f61229504
commit
c47548057d
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Do\saway\swith\sthe\s"multi-register\spseudo-table"\sabstration.\s\sInstead,\sjust\nuse\san\sOP_SCopy\sto\sload\sresults\sdirectory\sfrom\sthe\sresult\sregisters\sof\nthe\sco-routine.
|
||||
D 2014-02-08T23:20:32.439
|
||||
C Add\sa\snew\s"testset"\sto\sthe\sspeedtest1\sprogram:\s\sThe\ssudoku\ssolver.
|
||||
D 2014-02-09T00:18:21.530
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -824,7 +824,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
|
||||
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
|
||||
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
|
||||
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
|
||||
F test/speedtest1.c 7130d2cb6db45baa553a4ab2f715116c71c2d9f4
|
||||
F test/speedtest1.c ba90413e95df3b6e2ddc5b4568b2756f38ed8aa0
|
||||
F test/spellfix.test 61309f5efbec53603b3f86457d34a504f80abafe
|
||||
F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298
|
||||
F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de
|
||||
@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P e2303d1b0c17b6e7494fb7db8264f4c2ac193723
|
||||
R eb37dbfa0e5b1c125492efcb100d4ba8
|
||||
P 1e64dd782a126f48d78c43a664844a41d0e6334e
|
||||
R feb25dc752d56bb4a29200c4d7633cb5
|
||||
U drh
|
||||
Z 5d0b8c0ebed26b99f999abde70f4aea6
|
||||
Z 251505f9c01c1bcece10c5ebfc8b7c5b
|
||||
|
@ -1 +1 @@
|
||||
1e64dd782a126f48d78c43a664844a41d0e6334e
|
||||
4677ef2f8a726573c48ee2e532c00a68308dd7e1
|
@ -737,6 +737,118 @@ void testset_main(void){
|
||||
speedtest1_end_test();
|
||||
}
|
||||
|
||||
/*
|
||||
** A testset for common table expressions. This exercises code
|
||||
** for views, subqueries, co-routines, etc.
|
||||
*/
|
||||
void testset_cte(void){
|
||||
static const char *azPuzzle[] = {
|
||||
/* Easy */
|
||||
"534...9.."
|
||||
"67.195..."
|
||||
".98....6."
|
||||
"8...6...3"
|
||||
"4..8.3..1"
|
||||
"....2...6"
|
||||
".6....28."
|
||||
"...419..5"
|
||||
"...28..79",
|
||||
|
||||
/* Medium */
|
||||
"53....9.."
|
||||
"6..195..."
|
||||
".98....6."
|
||||
"8...6...3"
|
||||
"4..8.3..1"
|
||||
"....2...6"
|
||||
".6....28."
|
||||
"...419..5"
|
||||
"....8..79",
|
||||
|
||||
/* Hard */
|
||||
"53......."
|
||||
"6..195..."
|
||||
".98....6."
|
||||
"8...6...3"
|
||||
"4..8.3..1"
|
||||
"....2...6"
|
||||
".6....28."
|
||||
"...419..5"
|
||||
"....8..79",
|
||||
};
|
||||
const char *zPuz;
|
||||
|
||||
if( g.szTest<25 ){
|
||||
zPuz = azPuzzle[0];
|
||||
}else if( g.szTest<70 ){
|
||||
zPuz = azPuzzle[1];
|
||||
}else{
|
||||
zPuz = azPuzzle[2];
|
||||
}
|
||||
speedtest1_begin_test(100, "Sudoku with recursive 'digits'");
|
||||
speedtest1_prepare(
|
||||
"WITH RECURSIVE\n"
|
||||
" input(sud) AS (VALUES(?1)),\n"
|
||||
" digits(z,lp) AS (\n"
|
||||
" VALUES('1', 1)\n"
|
||||
" UNION ALL\n"
|
||||
" SELECT CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9\n"
|
||||
" ),\n"
|
||||
" x(s, ind) AS (\n"
|
||||
" SELECT sud, instr(sud, '.') FROM input\n"
|
||||
" UNION ALL\n"
|
||||
" SELECT\n"
|
||||
" substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
|
||||
" instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
|
||||
" FROM x, digits AS z\n"
|
||||
" WHERE ind>0\n"
|
||||
" AND NOT EXISTS (\n"
|
||||
" SELECT 1\n"
|
||||
" FROM digits AS lp\n"
|
||||
" WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
|
||||
" OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
|
||||
" OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
|
||||
" + ((ind-1)/27) * 27 + lp\n"
|
||||
" + ((lp-1) / 3) * 6, 1)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
"SELECT s FROM x WHERE ind=0;"
|
||||
);
|
||||
sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);
|
||||
speedtest1_run();
|
||||
speedtest1_end_test();
|
||||
|
||||
speedtest1_begin_test(200, "Sudoku with VALUES 'digits'");
|
||||
speedtest1_prepare(
|
||||
"WITH RECURSIVE\n"
|
||||
" input(sud) AS (VALUES(?1)),\n"
|
||||
" digits(z,lp) AS (VALUES('1',1),('2',2),('3',3),('4',4),('5',5),\n"
|
||||
" ('6',6),('7',7),('8',8),('9',9)),\n"
|
||||
" x(s, ind) AS (\n"
|
||||
" SELECT sud, instr(sud, '.') FROM input\n"
|
||||
" UNION ALL\n"
|
||||
" SELECT\n"
|
||||
" substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
|
||||
" instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
|
||||
" FROM x, digits AS z\n"
|
||||
" WHERE ind>0\n"
|
||||
" AND NOT EXISTS (\n"
|
||||
" SELECT 1\n"
|
||||
" FROM digits AS lp\n"
|
||||
" WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
|
||||
" OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
|
||||
" OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
|
||||
" + ((ind-1)/27) * 27 + lp\n"
|
||||
" + ((lp-1) / 3) * 6, 1)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
"SELECT s FROM x WHERE ind=0;"
|
||||
);
|
||||
sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);
|
||||
speedtest1_run();
|
||||
speedtest1_end_test();
|
||||
}
|
||||
|
||||
/*
|
||||
** A testset used for debugging speedtest1 itself.
|
||||
*/
|
||||
@ -945,6 +1057,8 @@ int main(int argc, char **argv){
|
||||
testset_main();
|
||||
}else if( strcmp(zTSet,"debug1")==0 ){
|
||||
testset_debug1();
|
||||
}else if( strcmp(zTSet,"cte")==0 ){
|
||||
testset_cte();
|
||||
}else{
|
||||
fatal_error("unknown testset: \"%s\"\n", zTSet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user