2 ** A program for performance testing.
4 ** The available command-line options are described below:
6 static const char zHelp
[] =
7 "Usage: %s [--options] DATABASE\n"
9 " --autovacuum Enable AUTOVACUUM mode\n"
10 " --cachesize N Set the cache size to N\n"
11 " --exclusive Enable locking_mode=EXCLUSIVE\n"
12 " --explain Like --sqlonly but with added EXPLAIN keywords\n"
13 " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
14 " --incrvacuum Enable incremenatal vacuum mode\n"
15 " --journal M Set the journal_mode to M\n"
16 " --key KEY Set the encryption key to KEY\n"
17 " --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
18 " --mmap SZ MMAP the first SZ bytes of the database file\n"
19 " --multithread Set multithreaded mode\n"
20 " --nomemstat Disable memory statistics\n"
21 " --nosync Set PRAGMA synchronous=OFF\n"
22 " --notnull Add NOT NULL constraints to table columns\n"
23 " --pagesize N Set the page size to N\n"
24 " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
25 " --primarykey Use PRIMARY KEY instead of UNIQUE where appropriate\n"
26 " --repeat N Repeat each SELECT N times (default: 1)\n"
27 " --reprepare Reprepare each statement upon every invocation\n"
28 " --serialized Set serialized threading mode\n"
29 " --singlethread Set single-threaded mode - disables all mutexing\n"
30 " --sqlonly No-op. Only show the SQL that would have been run.\n"
31 " --shrink-memory Invoke sqlite3_db_release_memory() frequently.\n"
32 " --size N Relative test size. Default=100\n"
33 " --stats Show statistics at the end\n"
34 " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n"
35 " --testset T Run test-set T (main, cte, rtree, orm, fp, debug)\n"
36 " --trace Turn on SQL tracing\n"
37 " --threads N Use up to N threads for sorting\n"
38 " --utf16be Set text encoding to UTF-16BE\n"
39 " --utf16le Set text encoding to UTF-16LE\n"
40 " --verify Run additional verification steps.\n"
41 " --without-rowid Use WITHOUT ROWID where appropriate\n"
57 #define ISSPACE(X) isspace((unsigned char)(X))
58 #define ISDIGIT(X) isdigit((unsigned char)(X))
60 #if SQLITE_VERSION_NUMBER<3005000
61 # define sqlite3_int64 sqlite_int64
64 /* All global state is held in this structure */
65 static struct Global
{
66 sqlite3
*db
; /* The open database connection */
67 sqlite3_stmt
*pStmt
; /* Current SQL statement */
68 sqlite3_int64 iStart
; /* Start-time for the current test */
69 sqlite3_int64 iTotal
; /* Total time */
70 int bWithoutRowid
; /* True for --without-rowid */
71 int bReprepare
; /* True to reprepare the SQL on each rerun */
72 int bSqlOnly
; /* True to print the SQL once only */
73 int bExplain
; /* Print SQL with EXPLAIN prefix */
74 int bVerify
; /* Try to verify that results are correct */
75 int bMemShrink
; /* Call sqlite3_db_release_memory() often */
76 int eTemp
; /* 0: no TEMP. 9: always TEMP. */
77 int szTest
; /* Scale factor for test iterations */
78 int nRepeat
; /* Repeat selects this many times */
79 const char *zWR
; /* Might be WITHOUT ROWID */
80 const char *zNN
; /* Might be NOT NULL */
81 const char *zPK
; /* Might be UNIQUE or PRIMARY KEY */
82 unsigned int x
, y
; /* Pseudo-random number generator state */
83 int nResult
; /* Size of the current result */
84 char zResult
[3000]; /* Text of the current result */
87 /* Return " TEMP" or "", as appropriate for creating a table.
89 static const char *isTemp(int N
){
90 return g
.eTemp
>=N
? " TEMP" : "";
94 /* Print an error message and exit */
95 static void fatal_error(const char *zMsg
, ...){
98 vfprintf(stderr
, zMsg
, ap
);
104 ** Return the value of a hexadecimal digit. Return -1 if the input
105 ** is not a hex digit.
107 static int hexDigitValue(char c
){
108 if( c
>='0' && c
<='9' ) return c
- '0';
109 if( c
>='a' && c
<='f' ) return c
- 'a' + 10;
110 if( c
>='A' && c
<='F' ) return c
- 'A' + 10;
114 /* Provide an alternative to sqlite3_stricmp() in older versions of
116 #if SQLITE_VERSION_NUMBER<3007011
117 # define sqlite3_stricmp strcmp
121 ** Interpret zArg as an integer value, possibly with suffixes.
123 static int integerValue(const char *zArg
){
125 static const struct { char *zSuffix
; int iMult
; } aMult
[] = {
127 { "MiB", 1024*1024 },
128 { "GiB", 1024*1024*1024 },
131 { "GB", 1000000000 },
141 }else if( zArg
[0]=='+' ){
144 if( zArg
[0]=='0' && zArg
[1]=='x' ){
147 while( (x
= hexDigitValue(zArg
[0]))>=0 ){
152 while( isdigit(zArg
[0]) ){
153 v
= v
*10 + zArg
[0] - '0';
157 for(i
=0; i
<sizeof(aMult
)/sizeof(aMult
[0]); i
++){
158 if( sqlite3_stricmp(aMult
[i
].zSuffix
, zArg
)==0 ){
163 if( v
>0x7fffffff ) fatal_error("parameter too large - max 2147483648");
164 return (int)(isNeg
? -v
: v
);
167 /* Return the current wall-clock time, in milliseconds */
168 sqlite3_int64
speedtest1_timestamp(void){
169 #if SQLITE_VERSION_NUMBER<3005000
172 static sqlite3_vfs
*clockVfs
= 0;
174 if( clockVfs
==0 ) clockVfs
= sqlite3_vfs_find(0);
175 #if SQLITE_VERSION_NUMBER>=3007000
176 if( clockVfs
->iVersion
>=2 && clockVfs
->xCurrentTimeInt64
!=0 ){
177 clockVfs
->xCurrentTimeInt64(clockVfs
, &t
);
182 clockVfs
->xCurrentTime(clockVfs
, &r
);
183 t
= (sqlite3_int64
)(r
*86400000.0);
189 /* Return a pseudo-random unsigned integer */
190 unsigned int speedtest1_random(void){
191 g
.x
= (g
.x
>>1) ^ ((1+~(g
.x
&1)) & 0xd0000001);
192 g
.y
= g
.y
*1103515245 + 12345;
196 /* Map the value in within the range of 1...limit into another
197 ** number in a way that is chatic and invertable.
199 unsigned swizzle(unsigned in
, unsigned limit
){
202 out
= (out
<<1) | (in
&1);
209 /* Round up a number so that it is a power of two minus one
211 unsigned roundup_allones(unsigned limit
){
213 while( m
<limit
) m
= (m
<<1)+1;
217 /* The speedtest1_numbername procedure below converts its argment (an integer)
218 ** into a string which is the English-language name for that number.
219 ** The returned string should be freed with sqlite3_free().
223 ** speedtest1_numbername(123) -> "one hundred twenty three"
225 int speedtest1_numbername(unsigned int n
, char *zOut
, int nOut
){
226 static const char *ones
[] = { "zero", "one", "two", "three", "four", "five",
227 "six", "seven", "eight", "nine", "ten", "eleven", "twelve",
228 "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
229 "eighteen", "nineteen" };
230 static const char *tens
[] = { "", "ten", "twenty", "thirty", "forty",
231 "fifty", "sixty", "seventy", "eighty", "ninety" };
235 i
+= speedtest1_numbername(n
/1000000000, zOut
+i
, nOut
-i
);
236 sqlite3_snprintf(nOut
-i
, zOut
+i
, " billion");
237 i
+= (int)strlen(zOut
+i
);
241 if( i
&& i
<nOut
-1 ) zOut
[i
++] = ' ';
242 i
+= speedtest1_numbername(n
/1000000, zOut
+i
, nOut
-i
);
243 sqlite3_snprintf(nOut
-i
, zOut
+i
, " million");
244 i
+= (int)strlen(zOut
+i
);
248 if( i
&& i
<nOut
-1 ) zOut
[i
++] = ' ';
249 i
+= speedtest1_numbername(n
/1000, zOut
+i
, nOut
-i
);
250 sqlite3_snprintf(nOut
-i
, zOut
+i
, " thousand");
251 i
+= (int)strlen(zOut
+i
);
255 if( i
&& i
<nOut
-1 ) zOut
[i
++] = ' ';
256 sqlite3_snprintf(nOut
-i
, zOut
+i
, "%s hundred", ones
[n
/100]);
257 i
+= (int)strlen(zOut
+i
);
261 if( i
&& i
<nOut
-1 ) zOut
[i
++] = ' ';
262 sqlite3_snprintf(nOut
-i
, zOut
+i
, "%s", tens
[n
/10]);
263 i
+= (int)strlen(zOut
+i
);
267 if( i
&& i
<nOut
-1 ) zOut
[i
++] = ' ';
268 sqlite3_snprintf(nOut
-i
, zOut
+i
, "%s", ones
[n
]);
269 i
+= (int)strlen(zOut
+i
);
272 sqlite3_snprintf(nOut
-i
, zOut
+i
, "zero");
273 i
+= (int)strlen(zOut
+i
);
279 /* Start a new test case */
281 static const char zDots
[] =
282 ".......................................................................";
283 void speedtest1_begin_test(int iTestNum
, const char *zTestName
, ...){
284 int n
= (int)strlen(zTestName
);
287 va_start(ap
, zTestName
);
288 zName
= sqlite3_vmprintf(zTestName
, ap
);
290 n
= (int)strlen(zName
);
292 zName
[NAMEWIDTH
] = 0;
296 printf("/* %4d - %s%.*s */\n", iTestNum
, zName
, NAMEWIDTH
-n
, zDots
);
298 printf("%4d - %s%.*s ", iTestNum
, zName
, NAMEWIDTH
-n
, zDots
);
303 g
.iStart
= speedtest1_timestamp();
308 /* Complete a test case */
309 void speedtest1_end_test(void){
310 sqlite3_int64 iElapseTime
= speedtest1_timestamp() - g
.iStart
;
312 g
.iTotal
+= iElapseTime
;
313 printf("%4d.%03ds\n", (int)(iElapseTime
/1000), (int)(iElapseTime
%1000));
316 sqlite3_finalize(g
.pStmt
);
321 /* Report end of testing */
322 void speedtest1_final(void){
324 printf(" TOTAL%.*s %4d.%03ds\n", NAMEWIDTH
-5, zDots
,
325 (int)(g
.iTotal
/1000), (int)(g
.iTotal
%1000));
329 /* Print an SQL statement to standard output */
330 static void printSql(const char *zSql
){
331 int n
= (int)strlen(zSql
);
332 while( n
>0 && (zSql
[n
-1]==';' || ISSPACE(zSql
[n
-1])) ){ n
--; }
333 if( g
.bExplain
) printf("EXPLAIN ");
334 printf("%.*s;\n", n
, zSql
);
336 #if SQLITE_VERSION_NUMBER>=3007017
337 && ( sqlite3_strglob("CREATE *", zSql
)==0
338 || sqlite3_strglob("DROP *", zSql
)==0
339 || sqlite3_strglob("ALTER *", zSql
)==0
343 printf("%.*s;\n", n
, zSql
);
347 /* Shrink memory used, if appropriate and if the SQLite version is capable
350 void speedtest1_shrink_memory(void){
351 #if SQLITE_VERSION_NUMBER>=3007010
352 if( g
.bMemShrink
) sqlite3_db_release_memory(g
.db
);
357 void speedtest1_exec(const char *zFormat
, ...){
360 va_start(ap
, zFormat
);
361 zSql
= sqlite3_vmprintf(zFormat
, ap
);
367 int rc
= sqlite3_exec(g
.db
, zSql
, 0, 0, &zErrMsg
);
368 if( zErrMsg
) fatal_error("SQL error: %s\n%s\n", zErrMsg
, zSql
);
369 if( rc
!=SQLITE_OK
) fatal_error("exec error: %s\n", sqlite3_errmsg(g
.db
));
372 speedtest1_shrink_memory();
375 /* Prepare an SQL statement */
376 void speedtest1_prepare(const char *zFormat
, ...){
379 va_start(ap
, zFormat
);
380 zSql
= sqlite3_vmprintf(zFormat
, ap
);
386 if( g
.pStmt
) sqlite3_finalize(g
.pStmt
);
387 rc
= sqlite3_prepare_v2(g
.db
, zSql
, -1, &g
.pStmt
, 0);
389 fatal_error("SQL error: %s\n", sqlite3_errmsg(g
.db
));
395 /* Run an SQL statement previously prepared */
396 void speedtest1_run(void){
398 if( g
.bSqlOnly
) return;
401 while( sqlite3_step(g
.pStmt
)==SQLITE_ROW
){
402 n
= sqlite3_column_count(g
.pStmt
);
404 const char *z
= (const char*)sqlite3_column_text(g
.pStmt
, i
);
405 if( z
==0 ) z
= "nil";
406 len
= (int)strlen(z
);
407 if( g
.nResult
+len
<sizeof(g
.zResult
)-2 ){
408 if( g
.nResult
>0 ) g
.zResult
[g
.nResult
++] = ' ';
409 memcpy(g
.zResult
+ g
.nResult
, z
, len
+1);
414 #if SQLITE_VERSION_NUMBER>=3006001
417 sqlite3_prepare_v2(g
.db
, sqlite3_sql(g
.pStmt
), -1, &pNew
, 0);
418 sqlite3_finalize(g
.pStmt
);
423 sqlite3_reset(g
.pStmt
);
425 speedtest1_shrink_memory();
428 #ifndef SQLITE_OMIT_DEPRECATED
429 /* The sqlite3_trace() callback function */
430 static void traceCallback(void *NotUsed
, const char *zSql
){
431 int n
= (int)strlen(zSql
);
432 while( n
>0 && (zSql
[n
-1]==';' || ISSPACE(zSql
[n
-1])) ) n
--;
433 fprintf(stderr
,"%.*s;\n", n
, zSql
);
435 #endif /* SQLITE_OMIT_DEPRECATED */
437 /* Substitute random() function that gives the same random
438 ** sequence on each run, for repeatability. */
439 static void randomFunc(
440 sqlite3_context
*context
,
442 sqlite3_value
**NotUsed2
444 sqlite3_result_int64(context
, (sqlite3_int64
)speedtest1_random());
447 /* Estimate the square root of an integer */
448 static int est_square_root(int x
){
452 for(n
=0; y0
>0 && n
<10; n
++){
461 #if SQLITE_VERSION_NUMBER<3005004
463 ** An implementation of group_concat(). Used only when testing older
464 ** versions of SQLite that lack the built-in group_concat().
471 static void groupAppend(struct groupConcat
*p
, const char *z
, int n
){
472 if( p
->nUsed
+n
>= p
->nAlloc
){
473 int n2
= (p
->nAlloc
+n
+1)*2;
474 char *z2
= sqlite3_realloc(p
->z
, n2
);
479 memcpy(p
->z
+p
->nUsed
, z
, n
);
482 static void groupStep(
483 sqlite3_context
*context
,
488 struct groupConcat
*p
;
491 assert( argc
==1 || argc
==2 );
492 if( sqlite3_value_type(argv
[0])==SQLITE_NULL
) return;
493 p
= (struct groupConcat
*)sqlite3_aggregate_context(context
, sizeof(*p
));
496 int firstTerm
= p
->nUsed
==0;
499 zSep
= (char*)sqlite3_value_text(argv
[1]);
500 nSep
= sqlite3_value_bytes(argv
[1]);
505 if( nSep
) groupAppend(p
, zSep
, nSep
);
507 zVal
= (char*)sqlite3_value_text(argv
[0]);
508 nVal
= sqlite3_value_bytes(argv
[0]);
509 if( zVal
) groupAppend(p
, zVal
, nVal
);
512 static void groupFinal(sqlite3_context
*context
){
513 struct groupConcat
*p
;
514 p
= sqlite3_aggregate_context(context
, 0);
517 sqlite3_result_text(context
, p
->z
, p
->nUsed
, sqlite3_free
);
523 ** The main and default testset
525 void testset_main(void){
526 int i
; /* Loop counter */
527 int n
; /* iteration count */
528 int sz
; /* Size of the tables */
529 int maxb
; /* Maximum swizzled value */
530 unsigned x1
= 0, x2
= 0; /* Parameters */
531 int len
= 0; /* Length of the zNum[] string */
532 char zNum
[2000]; /* A number name */
534 sz
= n
= g
.szTest
*500;
536 maxb
= roundup_allones(sz
);
537 speedtest1_begin_test(100, "%d INSERTs into table with no index", n
);
538 speedtest1_exec("BEGIN");
539 speedtest1_exec("CREATE%s TABLE t1(a INTEGER %s, b INTEGER %s, c TEXT %s);",
540 isTemp(9), g
.zNN
, g
.zNN
, g
.zNN
);
541 speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2,?3); -- %d times", n
);
543 x1
= swizzle(i
,maxb
);
544 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
545 sqlite3_bind_int64(g
.pStmt
, 1, (sqlite3_int64
)x1
);
546 sqlite3_bind_int(g
.pStmt
, 2, i
);
547 sqlite3_bind_text(g
.pStmt
, 3, zNum
, -1, SQLITE_STATIC
);
550 speedtest1_exec("COMMIT");
551 speedtest1_end_test();
555 speedtest1_begin_test(110, "%d ordered INSERTS with one index/PK", n
);
556 speedtest1_exec("BEGIN");
558 "CREATE%s TABLE t2(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s",
559 isTemp(5), g
.zNN
, g
.zPK
, g
.zNN
, g
.zNN
, g
.zWR
);
560 speedtest1_prepare("INSERT INTO t2 VALUES(?1,?2,?3); -- %d times", n
);
562 x1
= swizzle(i
,maxb
);
563 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
564 sqlite3_bind_int(g
.pStmt
, 1, i
);
565 sqlite3_bind_int64(g
.pStmt
, 2, (sqlite3_int64
)x1
);
566 sqlite3_bind_text(g
.pStmt
, 3, zNum
, -1, SQLITE_STATIC
);
569 speedtest1_exec("COMMIT");
570 speedtest1_end_test();
574 speedtest1_begin_test(120, "%d unordered INSERTS with one index/PK", n
);
575 speedtest1_exec("BEGIN");
577 "CREATE%s TABLE t3(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s",
578 isTemp(3), g
.zNN
, g
.zPK
, g
.zNN
, g
.zNN
, g
.zWR
);
579 speedtest1_prepare("INSERT INTO t3 VALUES(?1,?2,?3); -- %d times", n
);
581 x1
= swizzle(i
,maxb
);
582 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
583 sqlite3_bind_int(g
.pStmt
, 2, i
);
584 sqlite3_bind_int64(g
.pStmt
, 1, (sqlite3_int64
)x1
);
585 sqlite3_bind_text(g
.pStmt
, 3, zNum
, -1, SQLITE_STATIC
);
588 speedtest1_exec("COMMIT");
589 speedtest1_end_test();
591 #if SQLITE_VERSION_NUMBER<3005004
592 sqlite3_create_function(g
.db
, "group_concat", 1, SQLITE_UTF8
, 0,
593 0, groupStep
, groupFinal
);
597 speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n
);
598 speedtest1_exec("BEGIN");
600 "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n"
601 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n
604 if( (i
-1)%g
.nRepeat
==0 ){
605 x1
= speedtest1_random()%maxb
;
606 x2
= speedtest1_random()%10 + sz
/5000 + x1
;
608 sqlite3_bind_int(g
.pStmt
, 1, x1
);
609 sqlite3_bind_int(g
.pStmt
, 2, x2
);
612 speedtest1_exec("COMMIT");
613 speedtest1_end_test();
617 speedtest1_begin_test(140, "%d SELECTS, LIKE, unindexed", n
);
618 speedtest1_exec("BEGIN");
620 "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n"
621 " WHERE c LIKE ?1; -- %d times", n
624 if( (i
-1)%g
.nRepeat
==0 ){
625 x1
= speedtest1_random()%maxb
;
627 len
= speedtest1_numbername(i
, zNum
+1, sizeof(zNum
)-2);
631 sqlite3_bind_text(g
.pStmt
, 1, zNum
, len
+1, SQLITE_STATIC
);
634 speedtest1_exec("COMMIT");
635 speedtest1_end_test();
639 speedtest1_begin_test(142, "%d SELECTS w/ORDER BY, unindexed", n
);
640 speedtest1_exec("BEGIN");
642 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n"
643 " ORDER BY a; -- %d times", n
646 if( (i
-1)%g
.nRepeat
==0 ){
647 x1
= speedtest1_random()%maxb
;
649 len
= speedtest1_numbername(i
, zNum
+1, sizeof(zNum
)-2);
653 sqlite3_bind_text(g
.pStmt
, 1, zNum
, len
+1, SQLITE_STATIC
);
656 speedtest1_exec("COMMIT");
657 speedtest1_end_test();
659 n
= 10; /* g.szTest/5; */
660 speedtest1_begin_test(145, "%d SELECTS w/ORDER BY and LIMIT, unindexed", n
);
661 speedtest1_exec("BEGIN");
663 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n"
664 " ORDER BY a LIMIT 10; -- %d times", n
667 if( (i
-1)%g
.nRepeat
==0 ){
668 x1
= speedtest1_random()%maxb
;
670 len
= speedtest1_numbername(i
, zNum
+1, sizeof(zNum
)-2);
674 sqlite3_bind_text(g
.pStmt
, 1, zNum
, len
+1, SQLITE_STATIC
);
677 speedtest1_exec("COMMIT");
678 speedtest1_end_test();
681 speedtest1_begin_test(150, "CREATE INDEX five times");
682 speedtest1_exec("BEGIN;");
683 speedtest1_exec("CREATE UNIQUE INDEX t1b ON t1(b);");
684 speedtest1_exec("CREATE INDEX t1c ON t1(c);");
685 speedtest1_exec("CREATE UNIQUE INDEX t2b ON t2(b);");
686 speedtest1_exec("CREATE INDEX t2c ON t2(c DESC);");
687 speedtest1_exec("CREATE INDEX t3bc ON t3(b,c);");
688 speedtest1_exec("COMMIT;");
689 speedtest1_end_test();
693 speedtest1_begin_test(160, "%d SELECTS, numeric BETWEEN, indexed", n
);
694 speedtest1_exec("BEGIN");
696 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\n"
697 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n
700 if( (i
-1)%g
.nRepeat
==0 ){
701 x1
= speedtest1_random()%maxb
;
702 x2
= speedtest1_random()%10 + sz
/5000 + x1
;
704 sqlite3_bind_int(g
.pStmt
, 1, x1
);
705 sqlite3_bind_int(g
.pStmt
, 2, x2
);
708 speedtest1_exec("COMMIT");
709 speedtest1_end_test();
713 speedtest1_begin_test(161, "%d SELECTS, numeric BETWEEN, PK", n
);
714 speedtest1_exec("BEGIN");
716 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t2\n"
717 " WHERE a BETWEEN ?1 AND ?2; -- %d times", n
720 if( (i
-1)%g
.nRepeat
==0 ){
721 x1
= speedtest1_random()%maxb
;
722 x2
= speedtest1_random()%10 + sz
/5000 + x1
;
724 sqlite3_bind_int(g
.pStmt
, 1, x1
);
725 sqlite3_bind_int(g
.pStmt
, 2, x2
);
728 speedtest1_exec("COMMIT");
729 speedtest1_end_test();
733 speedtest1_begin_test(170, "%d SELECTS, text BETWEEN, indexed", n
);
734 speedtest1_exec("BEGIN");
736 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\n"
737 " WHERE c BETWEEN ?1 AND (?1||'~'); -- %d times", n
740 if( (i
-1)%g
.nRepeat
==0 ){
741 x1
= swizzle(i
, maxb
);
742 len
= speedtest1_numbername(x1
, zNum
, sizeof(zNum
)-1);
744 sqlite3_bind_text(g
.pStmt
, 1, zNum
, len
, SQLITE_STATIC
);
747 speedtest1_exec("COMMIT");
748 speedtest1_end_test();
751 speedtest1_begin_test(180, "%d INSERTS with three indexes", n
);
752 speedtest1_exec("BEGIN");
754 "CREATE%s TABLE t4(\n"
755 " a INTEGER %s %s,\n"
759 isTemp(1), g
.zNN
, g
.zPK
, g
.zNN
, g
.zNN
, g
.zWR
);
760 speedtest1_exec("CREATE INDEX t4b ON t4(b)");
761 speedtest1_exec("CREATE INDEX t4c ON t4(c)");
762 speedtest1_exec("INSERT INTO t4 SELECT * FROM t1");
763 speedtest1_exec("COMMIT");
764 speedtest1_end_test();
767 speedtest1_begin_test(190, "DELETE and REFILL one table", n
);
768 speedtest1_exec("DELETE FROM t2;");
769 speedtest1_exec("INSERT INTO t2 SELECT * FROM t1;");
770 speedtest1_end_test();
773 speedtest1_begin_test(200, "VACUUM");
774 speedtest1_exec("VACUUM");
775 speedtest1_end_test();
778 speedtest1_begin_test(210, "ALTER TABLE ADD COLUMN, and query");
779 speedtest1_exec("ALTER TABLE t2 ADD COLUMN d DEFAULT 123");
780 speedtest1_exec("SELECT sum(d) FROM t2");
781 speedtest1_end_test();
785 speedtest1_begin_test(230, "%d UPDATES, numeric BETWEEN, indexed", n
);
786 speedtest1_exec("BEGIN");
788 "UPDATE t2 SET d=b*2 WHERE b BETWEEN ?1 AND ?2; -- %d times", n
791 x1
= speedtest1_random()%maxb
;
792 x2
= speedtest1_random()%10 + sz
/5000 + x1
;
793 sqlite3_bind_int(g
.pStmt
, 1, x1
);
794 sqlite3_bind_int(g
.pStmt
, 2, x2
);
797 speedtest1_exec("COMMIT");
798 speedtest1_end_test();
802 speedtest1_begin_test(240, "%d UPDATES of individual rows", n
);
803 speedtest1_exec("BEGIN");
805 "UPDATE t2 SET d=b*3 WHERE a=?1; -- %d times", n
808 x1
= speedtest1_random()%sz
+ 1;
809 sqlite3_bind_int(g
.pStmt
, 1, x1
);
812 speedtest1_exec("COMMIT");
813 speedtest1_end_test();
815 speedtest1_begin_test(250, "One big UPDATE of the whole %d-row table", sz
);
816 speedtest1_exec("UPDATE t2 SET d=b*4");
817 speedtest1_end_test();
820 speedtest1_begin_test(260, "Query added column after filling");
821 speedtest1_exec("SELECT sum(d) FROM t2");
822 speedtest1_end_test();
827 speedtest1_begin_test(270, "%d DELETEs, numeric BETWEEN, indexed", n
);
828 speedtest1_exec("BEGIN");
830 "DELETE FROM t2 WHERE b BETWEEN ?1 AND ?2; -- %d times", n
833 x1
= speedtest1_random()%maxb
+ 1;
834 x2
= speedtest1_random()%10 + sz
/5000 + x1
;
835 sqlite3_bind_int(g
.pStmt
, 1, x1
);
836 sqlite3_bind_int(g
.pStmt
, 2, x2
);
839 speedtest1_exec("COMMIT");
840 speedtest1_end_test();
844 speedtest1_begin_test(280, "%d DELETEs of individual rows", n
);
845 speedtest1_exec("BEGIN");
847 "DELETE FROM t3 WHERE a=?1; -- %d times", n
850 x1
= speedtest1_random()%sz
+ 1;
851 sqlite3_bind_int(g
.pStmt
, 1, x1
);
854 speedtest1_exec("COMMIT");
855 speedtest1_end_test();
858 speedtest1_begin_test(290, "Refill two %d-row tables using REPLACE", sz
);
859 speedtest1_exec("REPLACE INTO t2(a,b,c) SELECT a,b,c FROM t1");
860 speedtest1_exec("REPLACE INTO t3(a,b,c) SELECT a,b,c FROM t1");
861 speedtest1_end_test();
863 speedtest1_begin_test(300, "Refill a %d-row table using (b&1)==(a&1)", sz
);
864 speedtest1_exec("DELETE FROM t2;");
865 speedtest1_exec("INSERT INTO t2(a,b,c)\n"
866 " SELECT a,b,c FROM t1 WHERE (b&1)==(a&1);");
867 speedtest1_exec("INSERT INTO t2(a,b,c)\n"
868 " SELECT a,b,c FROM t1 WHERE (b&1)<>(a&1);");
869 speedtest1_end_test();
873 speedtest1_begin_test(310, "%d four-ways joins", n
);
874 speedtest1_exec("BEGIN");
876 "SELECT t1.c FROM t1, t2, t3, t4\n"
877 " WHERE t4.a BETWEEN ?1 AND ?2\n"
883 x1
= speedtest1_random()%sz
+ 1;
884 x2
= speedtest1_random()%10 + x1
+ 4;
885 sqlite3_bind_int(g
.pStmt
, 1, x1
);
886 sqlite3_bind_int(g
.pStmt
, 2, x2
);
889 speedtest1_exec("COMMIT");
890 speedtest1_end_test();
892 speedtest1_begin_test(320, "subquery in result set", n
);
894 "SELECT sum(a), max(c),\n"
895 " avg((SELECT a FROM t2 WHERE 5+t2.b=t1.b) AND rowid<?1), max(c)\n"
896 " FROM t1 WHERE rowid<?1;"
898 sqlite3_bind_int(g
.pStmt
, 1, est_square_root(g
.szTest
)*50);
900 speedtest1_end_test();
902 sz
= n
= g
.szTest
*700;
904 maxb
= roundup_allones(sz
/3);
905 speedtest1_begin_test(400, "%d REPLACE ops on an IPK", n
);
906 speedtest1_exec("BEGIN");
907 speedtest1_exec("CREATE%s TABLE t5(a INTEGER PRIMARY KEY, b %s);",
909 speedtest1_prepare("REPLACE INTO t5 VALUES(?1,?2); -- %d times",n
);
911 x1
= swizzle(i
,maxb
);
912 speedtest1_numbername(i
, zNum
, sizeof(zNum
));
913 sqlite3_bind_int(g
.pStmt
, 1, (sqlite3_int64
)x1
);
914 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
917 speedtest1_exec("COMMIT");
918 speedtest1_end_test();
919 speedtest1_begin_test(410, "%d SELECTS on an IPK", n
);
920 speedtest1_prepare("SELECT b FROM t5 WHERE a=?1; -- %d times",n
);
922 x1
= swizzle(i
,maxb
);
923 sqlite3_bind_int(g
.pStmt
, 1, (sqlite3_int64
)x1
);
926 speedtest1_end_test();
928 sz
= n
= g
.szTest
*700;
930 maxb
= roundup_allones(sz
/3);
931 speedtest1_begin_test(500, "%d REPLACE on TEXT PK", n
);
932 speedtest1_exec("BEGIN");
933 speedtest1_exec("CREATE%s TABLE t6(a TEXT PRIMARY KEY, b %s)%s;",
935 sqlite3_libversion_number()>=3008002 ? "WITHOUT ROWID" : "");
936 speedtest1_prepare("REPLACE INTO t6 VALUES(?1,?2); -- %d times",n
);
938 x1
= swizzle(i
,maxb
);
939 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
940 sqlite3_bind_int(g
.pStmt
, 2, i
);
941 sqlite3_bind_text(g
.pStmt
, 1, zNum
, -1, SQLITE_STATIC
);
944 speedtest1_exec("COMMIT");
945 speedtest1_end_test();
946 speedtest1_begin_test(510, "%d SELECTS on a TEXT PK", n
);
947 speedtest1_prepare("SELECT b FROM t6 WHERE a=?1; -- %d times",n
);
949 x1
= swizzle(i
,maxb
);
950 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
951 sqlite3_bind_text(g
.pStmt
, 1, zNum
, -1, SQLITE_STATIC
);
954 speedtest1_end_test();
955 speedtest1_begin_test(520, "%d SELECT DISTINCT", n
);
956 speedtest1_exec("SELECT DISTINCT b FROM t5;");
957 speedtest1_exec("SELECT DISTINCT b FROM t6;");
958 speedtest1_end_test();
961 speedtest1_begin_test(980, "PRAGMA integrity_check");
962 speedtest1_exec("PRAGMA integrity_check");
963 speedtest1_end_test();
966 speedtest1_begin_test(990, "ANALYZE");
967 speedtest1_exec("ANALYZE");
968 speedtest1_end_test();
972 ** A testset for common table expressions. This exercises code
973 ** for views, subqueries, co-routines, etc.
975 void testset_cte(void){
976 static const char *azPuzzle
[] = {
1016 }else if( g
.szTest
<70 ){
1021 speedtest1_begin_test(100, "Sudoku with recursive 'digits'");
1024 " input(sud) AS (VALUES(?1)),\n"
1025 " digits(z,lp) AS (\n"
1028 " SELECT CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9\n"
1031 " SELECT sud, instr(sud, '.') FROM input\n"
1034 " substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
1035 " instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
1036 " FROM x, digits AS z\n"
1038 " AND NOT EXISTS (\n"
1040 " FROM digits AS lp\n"
1041 " WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
1042 " OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
1043 " OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
1044 " + ((ind-1)/27) * 27 + lp\n"
1045 " + ((lp-1) / 3) * 6, 1)\n"
1048 "SELECT s FROM x WHERE ind=0;"
1050 sqlite3_bind_text(g
.pStmt
, 1, zPuz
, -1, SQLITE_STATIC
);
1052 speedtest1_end_test();
1054 speedtest1_begin_test(200, "Sudoku with VALUES 'digits'");
1057 " input(sud) AS (VALUES(?1)),\n"
1058 " digits(z,lp) AS (VALUES('1',1),('2',2),('3',3),('4',4),('5',5),\n"
1059 " ('6',6),('7',7),('8',8),('9',9)),\n"
1061 " SELECT sud, instr(sud, '.') FROM input\n"
1064 " substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
1065 " instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
1066 " FROM x, digits AS z\n"
1068 " AND NOT EXISTS (\n"
1070 " FROM digits AS lp\n"
1071 " WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
1072 " OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
1073 " OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
1074 " + ((ind-1)/27) * 27 + lp\n"
1075 " + ((lp-1) / 3) * 6, 1)\n"
1078 "SELECT s FROM x WHERE ind=0;"
1080 sqlite3_bind_text(g
.pStmt
, 1, zPuz
, -1, SQLITE_STATIC
);
1082 speedtest1_end_test();
1084 rSpacing
= 5.0/g
.szTest
;
1085 speedtest1_begin_test(300, "Mandelbrot Set with spacing=%f", rSpacing
);
1088 " xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+?1 FROM xaxis WHERE x<1.2),\n"
1089 " yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+?2 FROM yaxis WHERE y<1.0),\n"
1090 " m(iter, cx, cy, x, y) AS (\n"
1091 " SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis\n"
1093 " SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m \n"
1094 " WHERE (x*x + y*y) < 4.0 AND iter<28\n"
1096 " m2(iter, cx, cy) AS (\n"
1097 " SELECT max(iter), cx, cy FROM m GROUP BY cx, cy\n"
1100 " SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') \n"
1101 " FROM m2 GROUP BY cy\n"
1103 "SELECT group_concat(rtrim(t),x'0a') FROM a;"
1105 sqlite3_bind_double(g
.pStmt
, 1, rSpacing
*.05);
1106 sqlite3_bind_double(g
.pStmt
, 2, rSpacing
);
1108 speedtest1_end_test();
1110 nElem
= 10000*g
.szTest
;
1111 speedtest1_begin_test(400, "EXCEPT operator on %d-element tables", nElem
);
1114 " t1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM t1 WHERE x<%d),\n"
1115 " t2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM t2 WHERE y<%d)\n"
1116 "SELECT count(x), avg(x) FROM (\n"
1117 " SELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1\n"
1122 speedtest1_end_test();
1126 ** Compute a pseudo-random floating point ascii number.
1128 void speedtest1_random_ascii_fp(char *zFP
){
1129 int x
= speedtest1_random();
1130 int y
= speedtest1_random();
1135 sqlite3_snprintf(100,zFP
,"%d.%de%d",y
,z
,x
%200);
1139 ** A testset for floating-point numbers.
1141 void testset_fp(void){
1148 speedtest1_begin_test(100, "Fill a table with %d FP values", n
*2);
1149 speedtest1_exec("BEGIN");
1150 speedtest1_exec("CREATE%s TABLE t1(a REAL %s, b REAL %s);",
1151 isTemp(1), g
.zNN
, g
.zNN
);
1152 speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2); -- %d times", n
);
1153 for(i
=1; i
<=n
; i
++){
1154 speedtest1_random_ascii_fp(zFP1
);
1155 speedtest1_random_ascii_fp(zFP2
);
1156 sqlite3_bind_text(g
.pStmt
, 1, zFP1
, -1, SQLITE_STATIC
);
1157 sqlite3_bind_text(g
.pStmt
, 2, zFP2
, -1, SQLITE_STATIC
);
1160 speedtest1_exec("COMMIT");
1161 speedtest1_end_test();
1163 n
= g
.szTest
/25 + 2;
1164 speedtest1_begin_test(110, "%d range queries", n
);
1165 speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
1166 for(i
=1; i
<=n
; i
++){
1167 speedtest1_random_ascii_fp(zFP1
);
1168 speedtest1_random_ascii_fp(zFP2
);
1169 sqlite3_bind_text(g
.pStmt
, 1, zFP1
, -1, SQLITE_STATIC
);
1170 sqlite3_bind_text(g
.pStmt
, 2, zFP2
, -1, SQLITE_STATIC
);
1173 speedtest1_end_test();
1175 speedtest1_begin_test(120, "CREATE INDEX three times");
1176 speedtest1_exec("BEGIN;");
1177 speedtest1_exec("CREATE INDEX t1a ON t1(a);");
1178 speedtest1_exec("CREATE INDEX t1b ON t1(b);");
1179 speedtest1_exec("CREATE INDEX t1ab ON t1(a,b);");
1180 speedtest1_exec("COMMIT;");
1181 speedtest1_end_test();
1184 speedtest1_begin_test(130, "%d indexed range queries", n
);
1185 speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
1186 for(i
=1; i
<=n
; i
++){
1187 speedtest1_random_ascii_fp(zFP1
);
1188 speedtest1_random_ascii_fp(zFP2
);
1189 sqlite3_bind_text(g
.pStmt
, 1, zFP1
, -1, SQLITE_STATIC
);
1190 sqlite3_bind_text(g
.pStmt
, 2, zFP2
, -1, SQLITE_STATIC
);
1193 speedtest1_end_test();
1196 #ifdef SQLITE_ENABLE_RTREE
1197 /* Generate two numbers between 1 and mx. The first number is less than
1198 ** the second. Usually the numbers are near each other but can sometimes
1201 static void twoCoords(
1202 int p1
, int p2
, /* Parameters adjusting sizes */
1203 unsigned mx
, /* Range of 1..mx */
1204 unsigned *pX0
, unsigned *pX1
/* OUT: write results here */
1206 unsigned d
, x0
, x1
, span
;
1209 if( speedtest1_random()%3==0 ) span
*= p1
;
1210 if( speedtest1_random()%p2
==0 ) span
= mx
/2;
1211 d
= speedtest1_random()%span
+ 1;
1212 x0
= speedtest1_random()%(mx
-d
) + 1;
1219 #ifdef SQLITE_ENABLE_RTREE
1220 /* The following routine is an R-Tree geometry callback. It returns
1221 ** true if the object overlaps a slice on the Y coordinate between the
1222 ** two values given as arguments. In other words
1224 ** SELECT count(*) FROM rt1 WHERE id MATCH xslice(10,20);
1226 ** Is the same as saying:
1228 ** SELECT count(*) FROM rt1 WHERE y1>=10 AND y0<=20;
1230 static int xsliceGeometryCallback(
1231 sqlite3_rtree_geometry
*p
,
1236 *pRes
= aCoord
[3]>=p
->aParam
[0] && aCoord
[2]<=p
->aParam
[1];
1239 #endif /* SQLITE_ENABLE_RTREE */
1241 #ifdef SQLITE_ENABLE_RTREE
1243 ** A testset for the R-Tree virtual table
1245 void testset_rtree(int p1
, int p2
){
1248 unsigned x0
, x1
, y0
, y1
, z0
, z1
;
1250 int *aCheck
= sqlite3_malloc( sizeof(int)*g
.szTest
*500 );
1254 speedtest1_begin_test(100, "%d INSERTs into an r-tree", n
);
1255 speedtest1_exec("BEGIN");
1256 speedtest1_exec("CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)");
1257 speedtest1_prepare("INSERT INTO rt1(id,x0,x1,y0,y1,z0,z1)"
1258 "VALUES(?1,?2,?3,?4,?5,?6,?7)");
1259 for(i
=1; i
<=n
; i
++){
1260 twoCoords(p1
, p2
, mxCoord
, &x0
, &x1
);
1261 twoCoords(p1
, p2
, mxCoord
, &y0
, &y1
);
1262 twoCoords(p1
, p2
, mxCoord
, &z0
, &z1
);
1263 sqlite3_bind_int(g
.pStmt
, 1, i
);
1264 sqlite3_bind_int(g
.pStmt
, 2, x0
);
1265 sqlite3_bind_int(g
.pStmt
, 3, x1
);
1266 sqlite3_bind_int(g
.pStmt
, 4, y0
);
1267 sqlite3_bind_int(g
.pStmt
, 5, y1
);
1268 sqlite3_bind_int(g
.pStmt
, 6, z0
);
1269 sqlite3_bind_int(g
.pStmt
, 7, z1
);
1272 speedtest1_exec("COMMIT");
1273 speedtest1_end_test();
1275 speedtest1_begin_test(101, "Copy from rtree to a regular table");
1276 speedtest1_exec("CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)");
1277 speedtest1_exec("INSERT INTO t1 SELECT * FROM rt1");
1278 speedtest1_end_test();
1281 speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n
);
1282 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2");
1285 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1286 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1288 aCheck
[i
] = atoi(g
.zResult
);
1290 speedtest1_end_test();
1294 speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries");
1295 speedtest1_prepare("SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2");
1298 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1299 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1301 if( aCheck
[i
]!=atoi(g
.zResult
) ){
1302 fatal_error("Count disagree step %d: %d..%d. %d vs %d",
1303 i
, i
*iStep
, (i
+1)*iStep
, aCheck
[i
], atoi(g
.zResult
));
1306 speedtest1_end_test();
1310 speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n
);
1311 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2");
1314 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1315 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1317 aCheck
[i
] = atoi(g
.zResult
);
1319 speedtest1_end_test();
1323 speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries");
1324 speedtest1_prepare("SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2");
1327 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1328 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1330 if( aCheck
[i
]!=atoi(g
.zResult
) ){
1331 fatal_error("Count disagree step %d: %d..%d. %d vs %d",
1332 i
, i
*iStep
, (i
+1)*iStep
, aCheck
[i
], atoi(g
.zResult
));
1335 speedtest1_end_test();
1340 speedtest1_begin_test(125, "%d custom geometry callback queries", n
);
1341 sqlite3_rtree_geometry_callback(g
.db
, "xslice", xsliceGeometryCallback
, 0);
1342 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)");
1345 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1346 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1348 if( aCheck
[i
]!=atoi(g
.zResult
) ){
1349 fatal_error("Count disagree step %d: %d..%d. %d vs %d",
1350 i
, i
*iStep
, (i
+1)*iStep
, aCheck
[i
], atoi(g
.zResult
));
1353 speedtest1_end_test();
1356 speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n
);
1357 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2"
1358 " AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2");
1361 sqlite3_bind_int(g
.pStmt
, 1, i
*iStep
);
1362 sqlite3_bind_int(g
.pStmt
, 2, (i
+1)*iStep
);
1364 aCheck
[i
] = atoi(g
.zResult
);
1366 speedtest1_end_test();
1369 speedtest1_begin_test(140, "%d rowid queries", n
);
1370 speedtest1_prepare("SELECT * FROM rt1 WHERE id=?1");
1371 for(i
=1; i
<=n
; i
++){
1372 sqlite3_bind_int(g
.pStmt
, 1, i
);
1375 speedtest1_end_test();
1377 #endif /* SQLITE_ENABLE_RTREE */
1380 ** A testset that does key/value storage on tables with many columns.
1381 ** This is the kind of workload generated by ORMs such as CoreData.
1383 void testset_orm(void){
1387 char zNum
[2000]; /* A number name */
1388 static const char zType
[] = /* Types for all non-PK columns, in order */
1389 "IBBIIITIVVITBTBFBFITTFBTBVBVIFTBBFITFFVBIFIVBVVVBTVTIBBFFIVIBTB"
1390 "TVTTFTVTVFFIITIFBITFTTFFFVBIIBTTITFTFFVVVFIIITVBBVFFTVVB";
1392 nRow
= n
= g
.szTest
*250;
1393 speedtest1_begin_test(100, "Fill %d rows", n
);
1396 "CREATE TABLE ZLOOKSLIKECOREDATA ("
1397 " ZPK INTEGER PRIMARY KEY,"
1398 " ZTERMFITTINGHOUSINGCOMMAND INTEGER,"
1399 " ZBRIEFGOBYDODGERHEIGHT BLOB,"
1400 " ZCAPABLETRIPDOORALMOND BLOB,"
1401 " ZDEPOSITPAIRCOLLEGECOMET INTEGER,"
1402 " ZFRAMEENTERSIMPLEMOUTH INTEGER,"
1403 " ZHOPEFULGATEHOLECHALK INTEGER,"
1404 " ZSLEEPYUSERGRANDBOWL TIMESTAMP,"
1405 " ZDEWPEACHCAREERCELERY INTEGER,"
1406 " ZHANGERLITHIUMDINNERMEET VARCHAR,"
1407 " ZCLUBRELEASELIZARDADVICE VARCHAR,"
1408 " ZCHARGECLICKHUMANEHIRE INTEGER,"
1409 " ZFINGERDUEPIZZAOPTION TIMESTAMP,"
1410 " ZFLYINGDOCTORTABLEMELODY BLOB,"
1411 " ZLONGFINLEAVEIMAGEOIL TIMESTAMP,"
1412 " ZFAMILYVISUALOWNERMATTER BLOB,"
1413 " ZGOLDYOUNGINITIALNOSE FLOAT,"
1414 " ZCAUSESALAMITERMCYAN BLOB,"
1415 " ZSPREADMOTORBISCUITBACON FLOAT,"
1416 " ZGIFTICEFISHGLUEHAIR INTEGER,"
1417 " ZNOTICEPEARPOLICYJUICE TIMESTAMP,"
1418 " ZBANKBUFFALORECOVERORBIT TIMESTAMP,"
1419 " ZLONGDIETESSAYNATURE FLOAT,"
1420 " ZACTIONRANGEELEGANTNEUTRON BLOB,"
1421 " ZCADETBRIGHTPLANETBANK TIMESTAMP,"
1422 " ZAIRFORGIVEHEADFROG BLOB,"
1423 " ZSHARKJUSTFRUITMOVIE VARCHAR,"
1424 " ZFARMERMORNINGMIRRORCONCERN BLOB,"
1425 " ZWOODPOETRYCOBBLERBENCH VARCHAR,"
1426 " ZHAFNIUMSCRIPTSALADMOTOR INTEGER,"
1427 " ZPROBLEMCLUBPOPOVERJELLY FLOAT,"
1428 " ZEIGHTLEADERWORKERMOST TIMESTAMP,"
1429 " ZGLASSRESERVEBARIUMMEAL BLOB,"
1430 " ZCLAMBITARUGULAFAJITA BLOB,"
1431 " ZDECADEJOYOUSWAVEHABIT FLOAT,"
1432 " ZCOMPANYSUMMERFIBERELF INTEGER,"
1433 " ZTREATTESTQUILLCHARGE TIMESTAMP,"
1434 " ZBROWBALANCEKEYCHOWDER FLOAT,"
1435 " ZPEACHCOPPERDINNERLAKE FLOAT,"
1436 " ZDRYWALLBEYONDBROWNBOWL VARCHAR,"
1437 " ZBELLYCRASHITEMLACK BLOB,"
1438 " ZTENNISCYCLEBILLOFFICER INTEGER,"
1439 " ZMALLEQUIPTHANKSGLUE FLOAT,"
1440 " ZMISSREPLYHUMANLIVING INTEGER,"
1441 " ZKIWIVISUALPRIDEAPPLE VARCHAR,"
1442 " ZWISHHITSKINMOTOR BLOB,"
1443 " ZCALMRACCOONPROGRAMDEBIT VARCHAR,"
1444 " ZSHINYASSISTLIVINGCRAB VARCHAR,"
1445 " ZRESOLVEWRISTWRAPAPPLE VARCHAR,"
1446 " ZAPPEALSIMPLESECONDHOUSING BLOB,"
1447 " ZCORNERANCHORTAPEDIVER TIMESTAMP,"
1448 " ZMEMORYREQUESTSOURCEBIG VARCHAR,"
1449 " ZTRYFACTKEEPMILK TIMESTAMP,"
1450 " ZDIVERPAINTLEATHEREASY INTEGER,"
1451 " ZSORTMISTYQUOTECABBAGE BLOB,"
1452 " ZTUNEGASBUFFALOCAPITAL BLOB,"
1453 " ZFILLSTOPLAWJOYFUL FLOAT,"
1454 " ZSTEELCAREFULPLATENUMBER FLOAT,"
1455 " ZGIVEVIVIDDIVINEMEANING INTEGER,"
1456 " ZTREATPACKFUTURECONVERT VARCHAR,"
1457 " ZCALMLYGEMFINISHEFFECT INTEGER,"
1458 " ZCABBAGESOCKEASEMINUTE BLOB,"
1459 " ZPLANETFAMILYPUREMEMORY TIMESTAMP,"
1460 " ZMERRYCRACKTRAINLEADER BLOB,"
1461 " ZMINORWAYPAPERCLASSY TIMESTAMP,"
1462 " ZEAGLELINEMINEMAIL VARCHAR,"
1463 " ZRESORTYARDGREENLET TIMESTAMP,"
1464 " ZYARDOREGANOVIVIDJEWEL TIMESTAMP,"
1465 " ZPURECAKEVIVIDNEATLY FLOAT,"
1466 " ZASKCONTACTMONITORFUN TIMESTAMP,"
1467 " ZMOVEWHOGAMMAINCH VARCHAR,"
1468 " ZLETTUCEBIRDMEETDEBATE TIMESTAMP,"
1469 " ZGENENATURALHEARINGKITE VARCHAR,"
1470 " ZMUFFINDRYERDRAWFORTUNE FLOAT,"
1471 " ZGRAYSURVEYWIRELOVE FLOAT,"
1472 " ZPLIERSPRINTASKOREGANO INTEGER,"
1473 " ZTRAVELDRIVERCONTESTLILY INTEGER,"
1474 " ZHUMORSPICESANDKIDNEY TIMESTAMP,"
1475 " ZARSENICSAMPLEWAITMUON INTEGER,"
1476 " ZLACEADDRESSGROUNDCAREFUL FLOAT,"
1477 " ZBAMBOOMESSWASABIEVENING BLOB,"
1478 " ZONERELEASEAVERAGENURSE INTEGER,"
1479 " ZRADIANTWHENTRYCARD TIMESTAMP,"
1480 " ZREWARDINSIDEMANGOINTENSE FLOAT,"
1481 " ZNEATSTEWPARTIRON TIMESTAMP,"
1482 " ZOUTSIDEPEAHENCOUNTICE TIMESTAMP,"
1483 " ZCREAMEVENINGLIPBRANCH FLOAT,"
1484 " ZWHALEMATHAVOCADOCOPPER FLOAT,"
1485 " ZLIFEUSELEAFYBELL FLOAT,"
1486 " ZWEALTHLINENGLEEFULDAY VARCHAR,"
1487 " ZFACEINVITETALKGOLD BLOB,"
1488 " ZWESTAMOUNTAFFECTHEARING INTEGER,"
1489 " ZDELAYOUTCOMEHORNAGENCY INTEGER,"
1490 " ZBIGTHINKCONVERTECONOMY BLOB,"
1491 " ZBASEGOUDAREGULARFORGIVE TIMESTAMP,"
1492 " ZPATTERNCLORINEGRANDCOLBY TIMESTAMP,"
1493 " ZCYANBASEFEEDADROIT INTEGER,"
1494 " ZCARRYFLOORMINNOWDRAGON TIMESTAMP,"
1495 " ZIMAGEPENCILOTHERBOTTOM FLOAT,"
1496 " ZXENONFLIGHTPALEAPPLE TIMESTAMP,"
1497 " ZHERRINGJOKEFEATUREHOPEFUL FLOAT,"
1498 " ZCAPYEARLYRIVETBRUSH FLOAT,"
1499 " ZAGEREEDFROGBASKET VARCHAR,"
1500 " ZUSUALBODYHALIBUTDIAMOND VARCHAR,"
1501 " ZFOOTTAPWORDENTRY VARCHAR,"
1502 " ZDISHKEEPBLESTMONITOR FLOAT,"
1503 " ZBROADABLESOLIDCASUAL INTEGER,"
1504 " ZSQUAREGLEEFULCHILDLIGHT INTEGER,"
1505 " ZHOLIDAYHEADPONYDETAIL INTEGER,"
1506 " ZGENERALRESORTSKYOPEN TIMESTAMP,"
1507 " ZGLADSPRAYKIDNEYGUPPY VARCHAR,"
1508 " ZSWIMHEAVYMENTIONKIND BLOB,"
1509 " ZMESSYSULFURDREAMFESTIVE BLOB,"
1510 " ZSKYSKYCLASSICBRIEF VARCHAR,"
1511 " ZDILLASKHOKILEMON FLOAT,"
1512 " ZJUNIORSHOWPRESSNOVA FLOAT,"
1513 " ZSIZETOEAWARDFRESH TIMESTAMP,"
1514 " ZKEYFAILAPRICOTMETAL VARCHAR,"
1515 " ZHANDYREPAIRPROTONAIRPORT VARCHAR,"
1516 " ZPOSTPROTEINHANDLEACTOR BLOB"
1520 "INSERT INTO ZLOOKSLIKECOREDATA(ZPK,ZAIRFORGIVEHEADFROG,"
1521 "ZGIFTICEFISHGLUEHAIR,ZDELAYOUTCOMEHORNAGENCY,ZSLEEPYUSERGRANDBOWL,"
1522 "ZGLASSRESERVEBARIUMMEAL,ZBRIEFGOBYDODGERHEIGHT,"
1523 "ZBAMBOOMESSWASABIEVENING,ZFARMERMORNINGMIRRORCONCERN,"
1524 "ZTREATPACKFUTURECONVERT,ZCAUSESALAMITERMCYAN,ZCALMRACCOONPROGRAMDEBIT,"
1525 "ZHOLIDAYHEADPONYDETAIL,ZWOODPOETRYCOBBLERBENCH,ZHAFNIUMSCRIPTSALADMOTOR,"
1526 "ZUSUALBODYHALIBUTDIAMOND,ZOUTSIDEPEAHENCOUNTICE,ZDIVERPAINTLEATHEREASY,"
1527 "ZWESTAMOUNTAFFECTHEARING,ZSIZETOEAWARDFRESH,ZDEWPEACHCAREERCELERY,"
1528 "ZSTEELCAREFULPLATENUMBER,ZCYANBASEFEEDADROIT,ZCALMLYGEMFINISHEFFECT,"
1529 "ZHANDYREPAIRPROTONAIRPORT,ZGENENATURALHEARINGKITE,ZBROADABLESOLIDCASUAL,"
1530 "ZPOSTPROTEINHANDLEACTOR,ZLACEADDRESSGROUNDCAREFUL,ZIMAGEPENCILOTHERBOTTOM,"
1531 "ZPROBLEMCLUBPOPOVERJELLY,ZPATTERNCLORINEGRANDCOLBY,ZNEATSTEWPARTIRON,"
1532 "ZAPPEALSIMPLESECONDHOUSING,ZMOVEWHOGAMMAINCH,ZTENNISCYCLEBILLOFFICER,"
1533 "ZSHARKJUSTFRUITMOVIE,ZKEYFAILAPRICOTMETAL,ZCOMPANYSUMMERFIBERELF,"
1534 "ZTERMFITTINGHOUSINGCOMMAND,ZRESORTYARDGREENLET,ZCABBAGESOCKEASEMINUTE,"
1535 "ZSQUAREGLEEFULCHILDLIGHT,ZONERELEASEAVERAGENURSE,ZBIGTHINKCONVERTECONOMY,"
1536 "ZPLIERSPRINTASKOREGANO,ZDECADEJOYOUSWAVEHABIT,ZDRYWALLBEYONDBROWNBOWL,"
1537 "ZCLUBRELEASELIZARDADVICE,ZWHALEMATHAVOCADOCOPPER,ZBELLYCRASHITEMLACK,"
1538 "ZLETTUCEBIRDMEETDEBATE,ZCAPABLETRIPDOORALMOND,ZRADIANTWHENTRYCARD,"
1539 "ZCAPYEARLYRIVETBRUSH,ZAGEREEDFROGBASKET,ZSWIMHEAVYMENTIONKIND,"
1540 "ZTRAVELDRIVERCONTESTLILY,ZGLADSPRAYKIDNEYGUPPY,ZBANKBUFFALORECOVERORBIT,"
1541 "ZFINGERDUEPIZZAOPTION,ZCLAMBITARUGULAFAJITA,ZLONGFINLEAVEIMAGEOIL,"
1542 "ZLONGDIETESSAYNATURE,ZJUNIORSHOWPRESSNOVA,ZHOPEFULGATEHOLECHALK,"
1543 "ZDEPOSITPAIRCOLLEGECOMET,ZWEALTHLINENGLEEFULDAY,ZFILLSTOPLAWJOYFUL,"
1544 "ZTUNEGASBUFFALOCAPITAL,ZGRAYSURVEYWIRELOVE,ZCORNERANCHORTAPEDIVER,"
1545 "ZREWARDINSIDEMANGOINTENSE,ZCADETBRIGHTPLANETBANK,ZPLANETFAMILYPUREMEMORY,"
1546 "ZTREATTESTQUILLCHARGE,ZCREAMEVENINGLIPBRANCH,ZSKYSKYCLASSICBRIEF,"
1547 "ZARSENICSAMPLEWAITMUON,ZBROWBALANCEKEYCHOWDER,ZFLYINGDOCTORTABLEMELODY,"
1548 "ZHANGERLITHIUMDINNERMEET,ZNOTICEPEARPOLICYJUICE,ZSHINYASSISTLIVINGCRAB,"
1549 "ZLIFEUSELEAFYBELL,ZFACEINVITETALKGOLD,ZGENERALRESORTSKYOPEN,"
1550 "ZPURECAKEVIVIDNEATLY,ZKIWIVISUALPRIDEAPPLE,ZMESSYSULFURDREAMFESTIVE,"
1551 "ZCHARGECLICKHUMANEHIRE,ZHERRINGJOKEFEATUREHOPEFUL,ZYARDOREGANOVIVIDJEWEL,"
1552 "ZFOOTTAPWORDENTRY,ZWISHHITSKINMOTOR,ZBASEGOUDAREGULARFORGIVE,"
1553 "ZMUFFINDRYERDRAWFORTUNE,ZACTIONRANGEELEGANTNEUTRON,ZTRYFACTKEEPMILK,"
1554 "ZPEACHCOPPERDINNERLAKE,ZFRAMEENTERSIMPLEMOUTH,ZMERRYCRACKTRAINLEADER,"
1555 "ZMEMORYREQUESTSOURCEBIG,ZCARRYFLOORMINNOWDRAGON,ZMINORWAYPAPERCLASSY,"
1556 "ZDILLASKHOKILEMON,ZRESOLVEWRISTWRAPAPPLE,ZASKCONTACTMONITORFUN,"
1557 "ZGIVEVIVIDDIVINEMEANING,ZEIGHTLEADERWORKERMOST,ZMISSREPLYHUMANLIVING,"
1558 "ZXENONFLIGHTPALEAPPLE,ZSORTMISTYQUOTECABBAGE,ZEAGLELINEMINEMAIL,"
1559 "ZFAMILYVISUALOWNERMATTER,ZSPREADMOTORBISCUITBACON,ZDISHKEEPBLESTMONITOR,"
1560 "ZMALLEQUIPTHANKSGLUE,ZGOLDYOUNGINITIALNOSE,ZHUMORSPICESANDKIDNEY)"
1561 "VALUES(?1,?26,?20,?93,?8,?33,?3,?81,?28,?60,?18,?47,?109,?29,?30,?104,?86,"
1562 "?54,?92,?117,?9,?58,?97,?61,?119,?73,?107,?120,?80,?99,?31,?96,?85,?50,?71,"
1563 "?42,?27,?118,?36,?2,?67,?62,?108,?82,?94,?76,?35,?40,?11,?88,?41,?72,?4,"
1564 "?83,?102,?103,?112,?77,?111,?22,?13,?34,?15,?23,?116,?7,?5,?90,?57,?56,"
1565 "?75,?51,?84,?25,?63,?37,?87,?114,?79,?38,?14,?10,?21,?48,?89,?91,?110,"
1566 "?69,?45,?113,?12,?101,?68,?105,?46,?95,?74,?24,?53,?39,?6,?64,?52,?98,"
1567 "?65,?115,?49,?70,?59,?32,?44,?100,?55,?66,?16,?19,?106,?43,?17,?78);"
1570 x1
= speedtest1_random();
1571 speedtest1_numbername(x1
%1000, zNum
, sizeof(zNum
));
1572 len
= (int)strlen(zNum
);
1573 sqlite3_bind_int(g
.pStmt
, 1, i
^0xf);
1574 for(j
=0; zType
[j
]; j
++){
1578 sqlite3_bind_int64(g
.pStmt
, j
+2, x1
);
1581 sqlite3_bind_double(g
.pStmt
, j
+2, (double)x1
);
1585 sqlite3_bind_text64(g
.pStmt
, j
+2, zNum
, len
,
1586 SQLITE_STATIC
, SQLITE_UTF8
);
1592 speedtest1_exec("COMMIT;");
1593 speedtest1_end_test();
1596 speedtest1_begin_test(110, "Query %d rows by rowid", n
);
1598 "SELECT ZCYANBASEFEEDADROIT,ZJUNIORSHOWPRESSNOVA,ZCAUSESALAMITERMCYAN,"
1599 "ZHOPEFULGATEHOLECHALK,ZHUMORSPICESANDKIDNEY,ZSWIMHEAVYMENTIONKIND,"
1600 "ZMOVEWHOGAMMAINCH,ZAPPEALSIMPLESECONDHOUSING,ZHAFNIUMSCRIPTSALADMOTOR,"
1601 "ZNEATSTEWPARTIRON,ZLONGFINLEAVEIMAGEOIL,ZDEWPEACHCAREERCELERY,"
1602 "ZXENONFLIGHTPALEAPPLE,ZCALMRACCOONPROGRAMDEBIT,ZUSUALBODYHALIBUTDIAMOND,"
1603 "ZTRYFACTKEEPMILK,ZWEALTHLINENGLEEFULDAY,ZLONGDIETESSAYNATURE,"
1604 "ZLIFEUSELEAFYBELL,ZTREATPACKFUTURECONVERT,ZMEMORYREQUESTSOURCEBIG,"
1605 "ZYARDOREGANOVIVIDJEWEL,ZDEPOSITPAIRCOLLEGECOMET,ZSLEEPYUSERGRANDBOWL,"
1606 "ZBRIEFGOBYDODGERHEIGHT,ZCLUBRELEASELIZARDADVICE,ZCAPABLETRIPDOORALMOND,"
1607 "ZDRYWALLBEYONDBROWNBOWL,ZASKCONTACTMONITORFUN,ZKIWIVISUALPRIDEAPPLE,"
1608 "ZNOTICEPEARPOLICYJUICE,ZPEACHCOPPERDINNERLAKE,ZSTEELCAREFULPLATENUMBER,"
1609 "ZGLADSPRAYKIDNEYGUPPY,ZCOMPANYSUMMERFIBERELF,ZTENNISCYCLEBILLOFFICER,"
1610 "ZIMAGEPENCILOTHERBOTTOM,ZWESTAMOUNTAFFECTHEARING,ZDIVERPAINTLEATHEREASY,"
1611 "ZSKYSKYCLASSICBRIEF,ZMESSYSULFURDREAMFESTIVE,ZMERRYCRACKTRAINLEADER,"
1612 "ZBROADABLESOLIDCASUAL,ZGLASSRESERVEBARIUMMEAL,ZTUNEGASBUFFALOCAPITAL,"
1613 "ZBANKBUFFALORECOVERORBIT,ZTREATTESTQUILLCHARGE,ZBAMBOOMESSWASABIEVENING,"
1614 "ZREWARDINSIDEMANGOINTENSE,ZEAGLELINEMINEMAIL,ZCALMLYGEMFINISHEFFECT,"
1615 "ZKEYFAILAPRICOTMETAL,ZFINGERDUEPIZZAOPTION,ZCADETBRIGHTPLANETBANK,"
1616 "ZGOLDYOUNGINITIALNOSE,ZMISSREPLYHUMANLIVING,ZEIGHTLEADERWORKERMOST,"
1617 "ZFRAMEENTERSIMPLEMOUTH,ZBIGTHINKCONVERTECONOMY,ZFACEINVITETALKGOLD,"
1618 "ZPOSTPROTEINHANDLEACTOR,ZHERRINGJOKEFEATUREHOPEFUL,ZCABBAGESOCKEASEMINUTE,"
1619 "ZMUFFINDRYERDRAWFORTUNE,ZPROBLEMCLUBPOPOVERJELLY,ZGIVEVIVIDDIVINEMEANING,"
1620 "ZGENENATURALHEARINGKITE,ZGENERALRESORTSKYOPEN,ZLETTUCEBIRDMEETDEBATE,"
1621 "ZBASEGOUDAREGULARFORGIVE,ZCHARGECLICKHUMANEHIRE,ZPLANETFAMILYPUREMEMORY,"
1622 "ZMINORWAYPAPERCLASSY,ZCAPYEARLYRIVETBRUSH,ZSIZETOEAWARDFRESH,"
1623 "ZARSENICSAMPLEWAITMUON,ZSQUAREGLEEFULCHILDLIGHT,ZSHINYASSISTLIVINGCRAB,"
1624 "ZCORNERANCHORTAPEDIVER,ZDECADEJOYOUSWAVEHABIT,ZTRAVELDRIVERCONTESTLILY,"
1625 "ZFLYINGDOCTORTABLEMELODY,ZSHARKJUSTFRUITMOVIE,ZFAMILYVISUALOWNERMATTER,"
1626 "ZFARMERMORNINGMIRRORCONCERN,ZGIFTICEFISHGLUEHAIR,ZOUTSIDEPEAHENCOUNTICE,"
1627 "ZSPREADMOTORBISCUITBACON,ZWISHHITSKINMOTOR,ZHOLIDAYHEADPONYDETAIL,"
1628 "ZWOODPOETRYCOBBLERBENCH,ZAIRFORGIVEHEADFROG,ZBROWBALANCEKEYCHOWDER,"
1629 "ZDISHKEEPBLESTMONITOR,ZCLAMBITARUGULAFAJITA,ZPLIERSPRINTASKOREGANO,"
1630 "ZRADIANTWHENTRYCARD,ZDELAYOUTCOMEHORNAGENCY,ZPURECAKEVIVIDNEATLY,"
1631 "ZPATTERNCLORINEGRANDCOLBY,ZHANDYREPAIRPROTONAIRPORT,ZAGEREEDFROGBASKET,"
1632 "ZSORTMISTYQUOTECABBAGE,ZFOOTTAPWORDENTRY,ZRESOLVEWRISTWRAPAPPLE,"
1633 "ZDILLASKHOKILEMON,ZFILLSTOPLAWJOYFUL,ZACTIONRANGEELEGANTNEUTRON,"
1634 "ZRESORTYARDGREENLET,ZCREAMEVENINGLIPBRANCH,ZWHALEMATHAVOCADOCOPPER,"
1635 "ZGRAYSURVEYWIRELOVE,ZBELLYCRASHITEMLACK,ZHANGERLITHIUMDINNERMEET,"
1636 "ZCARRYFLOORMINNOWDRAGON,ZMALLEQUIPTHANKSGLUE,ZTERMFITTINGHOUSINGCOMMAND,"
1637 "ZONERELEASEAVERAGENURSE,ZLACEADDRESSGROUNDCAREFUL"
1638 " FROM ZLOOKSLIKECOREDATA WHERE ZPK=?1;"
1641 x1
= speedtest1_random()%nRow
;
1642 sqlite3_bind_int(g
.pStmt
, 1, x1
);
1645 speedtest1_end_test();
1650 void testset_trigger(void){
1652 char zNum
[2000]; /* A number name */
1654 const int NROW
= 500*g
.szTest
;
1655 const int NROW2
= 100*g
.szTest
;
1659 "CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
1660 "CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
1661 "CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
1662 "CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;"
1663 "CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;"
1664 "CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;"
1666 for(jj
=1; jj
<=3; jj
++){
1667 speedtest1_prepare("INSERT INTO t%d VALUES(NULL,?1,?2)", jj
);
1668 for(ii
=0; ii
<NROW
; ii
++){
1669 int x1
= speedtest1_random() % NROW
;
1670 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
1671 sqlite3_bind_int(g
.pStmt
, 1, x1
);
1672 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
1677 "CREATE INDEX i1 ON t1(t);"
1678 "CREATE INDEX i2 ON t2(t);"
1679 "CREATE INDEX i3 ON t3(t);"
1683 speedtest1_begin_test(100, "speed4p-join1");
1685 "SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
1688 speedtest1_end_test();
1690 speedtest1_begin_test(110, "speed4p-join2");
1692 "SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
1695 speedtest1_end_test();
1697 speedtest1_begin_test(120, "speed4p-view1");
1698 for(jj
=1; jj
<=3; jj
++){
1699 speedtest1_prepare("SELECT * FROM v%d WHERE rowid = ?", jj
);
1700 for(ii
=0; ii
<NROW2
; ii
+=3){
1701 sqlite3_bind_int(g
.pStmt
, 1, ii
*3);
1705 speedtest1_end_test();
1707 speedtest1_begin_test(130, "speed4p-table1");
1708 for(jj
=1; jj
<=3; jj
++){
1709 speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj
);
1710 for(ii
=0; ii
<NROW2
; ii
+=3){
1711 sqlite3_bind_int(g
.pStmt
, 1, ii
*3);
1715 speedtest1_end_test();
1717 speedtest1_begin_test(140, "speed4p-table1");
1718 for(jj
=1; jj
<=3; jj
++){
1719 speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj
);
1720 for(ii
=0; ii
<NROW2
; ii
+=3){
1721 sqlite3_bind_int(g
.pStmt
, 1, ii
*3);
1725 speedtest1_end_test();
1727 speedtest1_begin_test(150, "speed4p-subselect1");
1728 speedtest1_prepare("SELECT "
1729 "(SELECT t FROM t1 WHERE rowid = ?1),"
1730 "(SELECT t FROM t2 WHERE rowid = ?1),"
1731 "(SELECT t FROM t3 WHERE rowid = ?1)"
1733 for(jj
=0; jj
<NROW2
; jj
++){
1734 sqlite3_bind_int(g
.pStmt
, 1, jj
*3);
1737 speedtest1_end_test();
1739 speedtest1_begin_test(160, "speed4p-rowid-update");
1740 speedtest1_exec("BEGIN");
1741 speedtest1_prepare("UPDATE t1 SET i=i+1 WHERE rowid=?1");
1742 for(jj
=0; jj
<NROW2
; jj
++){
1743 sqlite3_bind_int(g
.pStmt
, 1, jj
);
1746 speedtest1_exec("COMMIT");
1747 speedtest1_end_test();
1749 speedtest1_exec("CREATE TABLE t5(t TEXT PRIMARY KEY, i INTEGER);");
1750 speedtest1_begin_test(170, "speed4p-insert-ignore");
1751 speedtest1_exec("INSERT OR IGNORE INTO t5 SELECT t, i FROM t1");
1752 speedtest1_end_test();
1755 "CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);"
1756 "CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
1757 "CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN"
1758 " INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);"
1760 "CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN"
1761 " INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);"
1763 "CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN"
1764 " INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);"
1769 speedtest1_begin_test(180, "speed4p-trigger1");
1770 speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
1771 for(jj
=0; jj
<NROW2
; jj
++){
1772 speedtest1_numbername(jj
, zNum
, sizeof(zNum
));
1773 sqlite3_bind_int(g
.pStmt
, 1, jj
);
1774 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
1777 speedtest1_end_test();
1780 ** Note: Of the queries, only half actually update a row. This property
1781 ** was copied over from speed4p.test, where it was probably introduced
1784 speedtest1_begin_test(190, "speed4p-trigger2");
1785 speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
1786 for(jj
=1; jj
<=NROW2
*2; jj
+=2){
1787 speedtest1_numbername(jj
*2, zNum
, sizeof(zNum
));
1788 sqlite3_bind_int(g
.pStmt
, 1, jj
*2);
1789 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
1790 sqlite3_bind_int(g
.pStmt
, 3, jj
);
1793 speedtest1_end_test();
1796 ** Note: Same again.
1798 speedtest1_begin_test(200, "speed4p-trigger3");
1799 speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
1800 for(jj
=1; jj
<=NROW2
*2; jj
+=2){
1801 sqlite3_bind_int(g
.pStmt
, 1, jj
*2);
1804 speedtest1_end_test();
1805 speedtest1_exec("COMMIT");
1808 ** The following block contains the same tests as the above block that
1809 ** tests triggers, with one crucial difference: no triggers are defined.
1810 ** So the difference in speed between these tests and the preceding ones
1811 ** is the amount of time taken to compile and execute the trigger programs.
1817 "CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
1820 speedtest1_begin_test(210, "speed4p-notrigger1");
1821 speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
1822 for(jj
=0; jj
<NROW2
; jj
++){
1823 speedtest1_numbername(jj
, zNum
, sizeof(zNum
));
1824 sqlite3_bind_int(g
.pStmt
, 1, jj
);
1825 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
1828 speedtest1_end_test();
1829 speedtest1_begin_test(210, "speed4p-notrigger2");
1830 speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
1831 for(jj
=1; jj
<=NROW2
*2; jj
+=2){
1832 speedtest1_numbername(jj
*2, zNum
, sizeof(zNum
));
1833 sqlite3_bind_int(g
.pStmt
, 1, jj
*2);
1834 sqlite3_bind_text(g
.pStmt
, 2, zNum
, -1, SQLITE_STATIC
);
1835 sqlite3_bind_int(g
.pStmt
, 3, jj
);
1838 speedtest1_end_test();
1839 speedtest1_begin_test(220, "speed4p-notrigger3");
1840 speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
1841 for(jj
=1; jj
<=NROW2
*2; jj
+=2){
1842 sqlite3_bind_int(g
.pStmt
, 1, jj
*2);
1845 speedtest1_end_test();
1846 speedtest1_exec("COMMIT");
1850 ** A testset used for debugging speedtest1 itself.
1852 void testset_debug1(void){
1855 char zNum
[2000]; /* A number name */
1858 for(i
=1; i
<=n
; i
++){
1860 x2
= swizzle(x1
, n
);
1861 speedtest1_numbername(x1
, zNum
, sizeof(zNum
));
1862 printf("%5d %5d %5d %s\n", i
, x1
, x2
, zNum
);
1867 #include <sys/types.h>
1871 ** Attempt to display I/O stats on Linux using /proc/PID/io
1873 static void displayLinuxIoStats(FILE *out
){
1876 sqlite3_snprintf(sizeof(z
), z
, "/proc/%d/io", getpid());
1877 in
= fopen(z
, "rb");
1879 while( fgets(z
, sizeof(z
), in
)!=0 ){
1880 static const struct {
1881 const char *zPattern
;
1884 { "rchar: ", "Bytes received by read():" },
1885 { "wchar: ", "Bytes sent to write():" },
1886 { "syscr: ", "Read() system calls:" },
1887 { "syscw: ", "Write() system calls:" },
1888 { "read_bytes: ", "Bytes rcvd from storage:" },
1889 { "write_bytes: ", "Bytes sent to storage:" },
1890 { "cancelled_write_bytes: ", "Cancelled write bytes:" },
1893 for(i
=0; i
<sizeof(aTrans
)/sizeof(aTrans
[0]); i
++){
1894 int n
= (int)strlen(aTrans
[i
].zPattern
);
1895 if( strncmp(aTrans
[i
].zPattern
, z
, n
)==0 ){
1896 fprintf(out
, "-- %-28s %s", aTrans
[i
].zDesc
, &z
[n
]);
1905 #if SQLITE_VERSION_NUMBER<3006018
1906 # define sqlite3_sourceid(X) "(before 3.6.18)"
1909 static int xCompileOptions(void *pCtx
, int nVal
, char **azVal
, char **azCol
){
1910 printf("-- Compile option: %s\n", azVal
[0]);
1914 int main(int argc
, char **argv
){
1915 int doAutovac
= 0; /* True for --autovacuum */
1916 int cacheSize
= 0; /* Desired cache size. 0 means default */
1917 int doExclusive
= 0; /* True for --exclusive */
1918 int nHeap
= 0, mnHeap
= 0; /* Heap size from --heap */
1919 int doIncrvac
= 0; /* True for --incrvacuum */
1920 const char *zJMode
= 0; /* Journal mode */
1921 const char *zKey
= 0; /* Encryption key */
1922 int nLook
= -1, szLook
= 0; /* --lookaside configuration */
1923 int noSync
= 0; /* True for --nosync */
1924 int pageSize
= 0; /* Desired page size. 0 means default */
1925 int nPCache
= 0, szPCache
= 0;/* --pcache configuration */
1926 int doPCache
= 0; /* True if --pcache is seen */
1927 int showStats
= 0; /* True for --stats */
1928 int nThread
= 0; /* --threads value */
1929 int mmapSize
= 0; /* How big of a memory map to use */
1930 const char *zTSet
= "main"; /* Which --testset torun */
1931 int doTrace
= 0; /* True for --trace */
1932 const char *zEncoding
= 0; /* --utf16be or --utf16le */
1933 const char *zDbName
= 0; /* Name of the test database */
1935 void *pHeap
= 0; /* Allocated heap space */
1936 void *pLook
= 0; /* Allocated lookaside space */
1937 void *pPCache
= 0; /* Allocated storage for pcache */
1938 int iCur
, iHi
; /* Stats values, current and "highwater" */
1939 int i
; /* Loop counter */
1940 int rc
; /* API return code */
1942 /* Display the version of SQLite being tested */
1943 printf("-- Speedtest1 for SQLite %s %.50s\n",
1944 sqlite3_libversion(), sqlite3_sourceid());
1946 /* Process command-line arguments */
1952 for(i
=1; i
<argc
; i
++){
1953 const char *z
= argv
[i
];
1955 do{ z
++; }while( z
[0]=='-' );
1956 if( strcmp(z
,"autovacuum")==0 ){
1958 }else if( strcmp(z
,"cachesize")==0 ){
1959 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
1961 cacheSize
= integerValue(argv
[i
]);
1962 }else if( strcmp(z
,"exclusive")==0 ){
1964 }else if( strcmp(z
,"explain")==0 ){
1967 }else if( strcmp(z
,"heap")==0 ){
1968 if( i
>=argc
-2 ) fatal_error("missing arguments on %s\n", argv
[i
]);
1969 nHeap
= integerValue(argv
[i
+1]);
1970 mnHeap
= integerValue(argv
[i
+2]);
1972 }else if( strcmp(z
,"incrvacuum")==0 ){
1974 }else if( strcmp(z
,"journal")==0 ){
1975 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
1977 }else if( strcmp(z
,"key")==0 ){
1978 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
1980 }else if( strcmp(z
,"lookaside")==0 ){
1981 if( i
>=argc
-2 ) fatal_error("missing arguments on %s\n", argv
[i
]);
1982 nLook
= integerValue(argv
[i
+1]);
1983 szLook
= integerValue(argv
[i
+2]);
1985 #if SQLITE_VERSION_NUMBER>=3006000
1986 }else if( strcmp(z
,"multithread")==0 ){
1987 sqlite3_config(SQLITE_CONFIG_MULTITHREAD
);
1988 }else if( strcmp(z
,"nomemstat")==0 ){
1989 sqlite3_config(SQLITE_CONFIG_MEMSTATUS
, 0);
1991 #if SQLITE_VERSION_NUMBER>=3007017
1992 }else if( strcmp(z
, "mmap")==0 ){
1993 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
1994 mmapSize
= integerValue(argv
[++i
]);
1996 }else if( strcmp(z
,"nosync")==0 ){
1998 }else if( strcmp(z
,"notnull")==0 ){
2000 }else if( strcmp(z
,"pagesize")==0 ){
2001 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
2002 pageSize
= integerValue(argv
[++i
]);
2003 }else if( strcmp(z
,"pcache")==0 ){
2004 if( i
>=argc
-2 ) fatal_error("missing arguments on %s\n", argv
[i
]);
2005 nPCache
= integerValue(argv
[i
+1]);
2006 szPCache
= integerValue(argv
[i
+2]);
2009 }else if( strcmp(z
,"primarykey")==0 ){
2010 g
.zPK
= "PRIMARY KEY";
2011 }else if( strcmp(z
,"repeat")==0 ){
2012 if( i
>=argc
-1 ) fatal_error("missing arguments on %s\n", argv
[i
]);
2013 g
.nRepeat
= integerValue(argv
[i
+1]);
2015 }else if( strcmp(z
,"reprepare")==0 ){
2017 #if SQLITE_VERSION_NUMBER>=3006000
2018 }else if( strcmp(z
,"serialized")==0 ){
2019 sqlite3_config(SQLITE_CONFIG_SERIALIZED
);
2020 }else if( strcmp(z
,"singlethread")==0 ){
2021 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD
);
2023 }else if( strcmp(z
,"sqlonly")==0 ){
2025 }else if( strcmp(z
,"shrink-memory")==0 ){
2027 }else if( strcmp(z
,"size")==0 ){
2028 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
2029 g
.szTest
= integerValue(argv
[++i
]);
2030 }else if( strcmp(z
,"stats")==0 ){
2032 }else if( strcmp(z
,"temp")==0 ){
2033 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
2035 if( argv
[i
][0]<'0' || argv
[i
][0]>'9' || argv
[i
][1]!=0 ){
2036 fatal_error("argument to --temp should be integer between 0 and 9");
2038 g
.eTemp
= argv
[i
][0] - '0';
2039 }else if( strcmp(z
,"testset")==0 ){
2040 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
2042 }else if( strcmp(z
,"trace")==0 ){
2044 }else if( strcmp(z
,"threads")==0 ){
2045 if( i
>=argc
-1 ) fatal_error("missing argument on %s\n", argv
[i
]);
2046 nThread
= integerValue(argv
[++i
]);
2047 }else if( strcmp(z
,"utf16le")==0 ){
2048 zEncoding
= "utf16le";
2049 }else if( strcmp(z
,"utf16be")==0 ){
2050 zEncoding
= "utf16be";
2051 }else if( strcmp(z
,"verify")==0 ){
2053 }else if( strcmp(z
,"without-rowid")==0 ){
2054 g
.zWR
= "WITHOUT ROWID";
2055 g
.zPK
= "PRIMARY KEY";
2056 }else if( strcmp(z
, "help")==0 || strcmp(z
,"?")==0 ){
2057 printf(zHelp
, argv
[0]);
2060 fatal_error("unknown option: %s\nUse \"%s -?\" for help\n",
2063 }else if( zDbName
==0 ){
2066 fatal_error("surplus argument: %s\nUse \"%s -?\" for help\n",
2070 if( zDbName
!=0 ) unlink(zDbName
);
2071 #if SQLITE_VERSION_NUMBER>=3006001
2073 pHeap
= malloc( nHeap
);
2074 if( pHeap
==0 ) fatal_error("cannot allocate %d-byte heap\n", nHeap
);
2075 rc
= sqlite3_config(SQLITE_CONFIG_HEAP
, pHeap
, nHeap
, mnHeap
);
2076 if( rc
) fatal_error("heap configuration failed: %d\n", rc
);
2079 if( nPCache
>0 && szPCache
>0 ){
2080 pPCache
= malloc( nPCache
*(sqlite3_int64
)szPCache
);
2081 if( pPCache
==0 ) fatal_error("cannot allocate %lld-byte pcache\n",
2082 nPCache
*(sqlite3_int64
)szPCache
);
2084 rc
= sqlite3_config(SQLITE_CONFIG_PAGECACHE
, pPCache
, szPCache
, nPCache
);
2085 if( rc
) fatal_error("pcache configuration failed: %d\n", rc
);
2088 sqlite3_config(SQLITE_CONFIG_LOOKASIDE
, 0, 0);
2092 /* Open the database and the input file */
2093 if( sqlite3_open(zDbName
, &g
.db
) ){
2094 fatal_error("Cannot open database file: %s\n", zDbName
);
2096 #if SQLITE_VERSION_NUMBER>=3006001
2097 if( nLook
>0 && szLook
>0 ){
2098 pLook
= malloc( nLook
*szLook
);
2099 rc
= sqlite3_db_config(g
.db
, SQLITE_DBCONFIG_LOOKASIDE
, pLook
, szLook
,nLook
);
2100 if( rc
) fatal_error("lookaside configuration failed: %d\n", rc
);
2104 /* Set database connection options */
2105 sqlite3_create_function(g
.db
, "random", 0, SQLITE_UTF8
, 0, randomFunc
, 0, 0);
2106 #ifndef SQLITE_OMIT_DEPRECATED
2107 if( doTrace
) sqlite3_trace(g
.db
, traceCallback
, 0);
2110 speedtest1_exec("PRAGMA mmap_size=%d", mmapSize
);
2112 speedtest1_exec("PRAGMA threads=%d", nThread
);
2114 speedtest1_exec("PRAGMA key('%s')", zKey
);
2117 speedtest1_exec("PRAGMA encoding=%s", zEncoding
);
2120 speedtest1_exec("PRAGMA auto_vacuum=FULL");
2121 }else if( doIncrvac
){
2122 speedtest1_exec("PRAGMA auto_vacuum=INCREMENTAL");
2125 speedtest1_exec("PRAGMA page_size=%d", pageSize
);
2128 speedtest1_exec("PRAGMA cache_size=%d", cacheSize
);
2130 if( noSync
) speedtest1_exec("PRAGMA synchronous=OFF");
2132 speedtest1_exec("PRAGMA locking_mode=EXCLUSIVE");
2135 speedtest1_exec("PRAGMA journal_mode=%s", zJMode
);
2138 if( g
.bExplain
) printf(".explain\n.echo on\n");
2139 if( strcmp(zTSet
,"main")==0 ){
2141 }else if( strcmp(zTSet
,"debug1")==0 ){
2143 }else if( strcmp(zTSet
,"orm")==0 ){
2145 }else if( strcmp(zTSet
,"cte")==0 ){
2147 }else if( strcmp(zTSet
,"fp")==0 ){
2149 }else if( strcmp(zTSet
,"trigger")==0 ){
2151 }else if( strcmp(zTSet
,"rtree")==0 ){
2152 #ifdef SQLITE_ENABLE_RTREE
2153 testset_rtree(6, 147);
2155 fatal_error("compile with -DSQLITE_ENABLE_RTREE to enable "
2156 "the R-Tree tests\n");
2159 fatal_error("unknown testset: \"%s\"\n"
2160 "Choices: cte debug1 fp main orm rtree trigger\n",
2166 sqlite3_exec(g
.db
, "PRAGMA compile_options", xCompileOptions
, 0, 0);
2169 /* Database connection statistics printed after both prepared statements
2170 ** have been finalized */
2171 #if SQLITE_VERSION_NUMBER>=3007009
2173 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_LOOKASIDE_USED
, &iCur
, &iHi
, 0);
2174 printf("-- Lookaside Slots Used: %d (max %d)\n", iCur
,iHi
);
2175 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_LOOKASIDE_HIT
, &iCur
, &iHi
, 0);
2176 printf("-- Successful lookasides: %d\n", iHi
);
2177 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
, &iCur
,&iHi
,0);
2178 printf("-- Lookaside size faults: %d\n", iHi
);
2179 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
, &iCur
,&iHi
,0);
2180 printf("-- Lookaside OOM faults: %d\n", iHi
);
2181 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_CACHE_USED
, &iCur
, &iHi
, 0);
2182 printf("-- Pager Heap Usage: %d bytes\n", iCur
);
2183 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_CACHE_HIT
, &iCur
, &iHi
, 1);
2184 printf("-- Page cache hits: %d\n", iCur
);
2185 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_CACHE_MISS
, &iCur
, &iHi
, 1);
2186 printf("-- Page cache misses: %d\n", iCur
);
2187 #if SQLITE_VERSION_NUMBER>=3007012
2188 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_CACHE_WRITE
, &iCur
, &iHi
, 1);
2189 printf("-- Page cache writes: %d\n", iCur
);
2191 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_SCHEMA_USED
, &iCur
, &iHi
, 0);
2192 printf("-- Schema Heap Usage: %d bytes\n", iCur
);
2193 sqlite3_db_status(g
.db
, SQLITE_DBSTATUS_STMT_USED
, &iCur
, &iHi
, 0);
2194 printf("-- Statement Heap Usage: %d bytes\n", iCur
);
2198 sqlite3_close(g
.db
);
2200 #if SQLITE_VERSION_NUMBER>=3006001
2201 /* Global memory usage statistics printed after the database connection
2202 ** has closed. Memory usage should be zero at this point. */
2204 sqlite3_status(SQLITE_STATUS_MEMORY_USED
, &iCur
, &iHi
, 0);
2205 printf("-- Memory Used (bytes): %d (max %d)\n", iCur
,iHi
);
2206 #if SQLITE_VERSION_NUMBER>=3007000
2207 sqlite3_status(SQLITE_STATUS_MALLOC_COUNT
, &iCur
, &iHi
, 0);
2208 printf("-- Outstanding Allocations: %d (max %d)\n", iCur
,iHi
);
2210 sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW
, &iCur
, &iHi
, 0);
2211 printf("-- Pcache Overflow Bytes: %d (max %d)\n", iCur
,iHi
);
2212 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE
, &iCur
, &iHi
, 0);
2213 printf("-- Largest Allocation: %d bytes\n",iHi
);
2214 sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE
, &iCur
, &iHi
, 0);
2215 printf("-- Largest Pcache Allocation: %d bytes\n",iHi
);
2221 displayLinuxIoStats(stdout
);
2225 /* Release memory */