OLD | NEW |
1 /* | 1 /* |
2 ** A program for performance testing. | 2 ** A program for performance testing. |
3 ** | 3 ** |
4 ** The available command-line options are described below: | 4 ** The available command-line options are described below: |
5 */ | 5 */ |
6 static const char zHelp[] = | 6 static const char zHelp[] = |
7 "Usage: %s [--options] DATABASE\n" | 7 "Usage: %s [--options] DATABASE\n" |
8 "Options:\n" | 8 "Options:\n" |
9 " --autovacuum Enable AUTOVACUUM mode\n" | 9 " --autovacuum Enable AUTOVACUUM mode\n" |
10 " --cachesize N Set the cache size to N\n" | 10 " --cachesize N Set the cache size to N\n" |
11 " --exclusive Enable locking_mode=EXCLUSIVE\n" | 11 " --exclusive Enable locking_mode=EXCLUSIVE\n" |
12 " --explain Like --sqlonly but with added EXPLAIN keywords\n" | 12 " --explain Like --sqlonly but with added EXPLAIN keywords\n" |
13 " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n" | 13 " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n" |
14 " --incrvacuum Enable incremenatal vacuum mode\n" | 14 " --incrvacuum Enable incremenatal vacuum mode\n" |
15 " --journal M Set the journal_mode to M\n" | 15 " --journal M Set the journal_mode to M\n" |
16 " --key KEY Set the encryption key to KEY\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" | 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" |
18 " --multithread Set multithreaded mode\n" | 19 " --multithread Set multithreaded mode\n" |
19 " --nomemstat Disable memory statistics\n" | 20 " --nomemstat Disable memory statistics\n" |
20 " --nosync Set PRAGMA synchronous=OFF\n" | 21 " --nosync Set PRAGMA synchronous=OFF\n" |
21 " --notnull Add NOT NULL constraints to table columns\n" | 22 " --notnull Add NOT NULL constraints to table columns\n" |
22 " --pagesize N Set the page size to N\n" | 23 " --pagesize N Set the page size to N\n" |
23 " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n" | 24 " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n" |
24 " --primarykey Use PRIMARY KEY instead of UNIQUE where appropriate\n" | 25 " --primarykey Use PRIMARY KEY instead of UNIQUE where appropriate\n" |
| 26 " --repeat N Repeat each SELECT N times (default: 1)\n" |
25 " --reprepare Reprepare each statement upon every invocation\n" | 27 " --reprepare Reprepare each statement upon every invocation\n" |
26 " --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n
" | 28 " --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n
" |
27 " --serialized Set serialized threading mode\n" | 29 " --serialized Set serialized threading mode\n" |
28 " --singlethread Set single-threaded mode - disables all mutexing\n" | 30 " --singlethread Set single-threaded mode - disables all mutexing\n" |
29 " --sqlonly No-op. Only show the SQL that would have been run.\n" | 31 " --sqlonly No-op. Only show the SQL that would have been run.\n" |
30 " --shrink-memory Invoke sqlite3_db_release_memory() frequently.\n" | 32 " --shrink-memory Invoke sqlite3_db_release_memory() frequently.\n" |
31 " --size N Relative test size. Default=100\n" | 33 " --size N Relative test size. Default=100\n" |
32 " --stats Show statistics at the end\n" | 34 " --stats Show statistics at the end\n" |
| 35 " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n" |
33 " --testset T Run test-set T\n" | 36 " --testset T Run test-set T\n" |
34 " --trace Turn on SQL tracing\n" | 37 " --trace Turn on SQL tracing\n" |
35 " --threads N Use up to N threads for sorting\n" | 38 " --threads N Use up to N threads for sorting\n" |
36 " --utf16be Set text encoding to UTF-16BE\n" | 39 " --utf16be Set text encoding to UTF-16BE\n" |
37 " --utf16le Set text encoding to UTF-16LE\n" | 40 " --utf16le Set text encoding to UTF-16LE\n" |
38 " --verify Run additional verification steps.\n" | 41 " --verify Run additional verification steps.\n" |
39 " --without-rowid Use WITHOUT ROWID where appropriate\n" | 42 " --without-rowid Use WITHOUT ROWID where appropriate\n" |
40 ; | 43 ; |
41 | 44 |
42 | 45 |
43 #include "sqlite3.h" | 46 #include "sqlite3.h" |
44 #include <assert.h> | 47 #include <assert.h> |
45 #include <stdio.h> | 48 #include <stdio.h> |
46 #include <stdlib.h> | 49 #include <stdlib.h> |
47 #include <stdarg.h> | 50 #include <stdarg.h> |
48 #include <string.h> | 51 #include <string.h> |
49 #include <ctype.h> | 52 #include <ctype.h> |
| 53 #ifndef _WIN32 |
| 54 # include <unistd.h> |
| 55 #else |
| 56 # include <io.h> |
| 57 #endif |
50 #define ISSPACE(X) isspace((unsigned char)(X)) | 58 #define ISSPACE(X) isspace((unsigned char)(X)) |
51 #define ISDIGIT(X) isdigit((unsigned char)(X)) | 59 #define ISDIGIT(X) isdigit((unsigned char)(X)) |
52 | 60 |
53 #if SQLITE_VERSION_NUMBER<3005000 | 61 #if SQLITE_VERSION_NUMBER<3005000 |
54 # define sqlite3_int64 sqlite_int64 | 62 # define sqlite3_int64 sqlite_int64 |
55 #endif | 63 #endif |
56 #ifdef SQLITE_ENABLE_RBU | |
57 # include "sqlite3rbu.h" | |
58 #endif | |
59 | 64 |
60 /* All global state is held in this structure */ | 65 /* All global state is held in this structure */ |
61 static struct Global { | 66 static struct Global { |
62 sqlite3 *db; /* The open database connection */ | 67 sqlite3 *db; /* The open database connection */ |
63 sqlite3_stmt *pStmt; /* Current SQL statement */ | 68 sqlite3_stmt *pStmt; /* Current SQL statement */ |
64 sqlite3_int64 iStart; /* Start-time for the current test */ | 69 sqlite3_int64 iStart; /* Start-time for the current test */ |
65 sqlite3_int64 iTotal; /* Total time */ | 70 sqlite3_int64 iTotal; /* Total time */ |
66 int bWithoutRowid; /* True for --without-rowid */ | 71 int bWithoutRowid; /* True for --without-rowid */ |
67 int bReprepare; /* True to reprepare the SQL on each rerun */ | 72 int bReprepare; /* True to reprepare the SQL on each rerun */ |
68 int bSqlOnly; /* True to print the SQL once only */ | 73 int bSqlOnly; /* True to print the SQL once only */ |
69 int bExplain; /* Print SQL with EXPLAIN prefix */ | 74 int bExplain; /* Print SQL with EXPLAIN prefix */ |
70 int bVerify; /* Try to verify that results are correct */ | 75 int bVerify; /* Try to verify that results are correct */ |
71 int bMemShrink; /* Call sqlite3_db_release_memory() often */ | 76 int bMemShrink; /* Call sqlite3_db_release_memory() often */ |
| 77 int eTemp; /* 0: no TEMP. 9: always TEMP. */ |
72 int szTest; /* Scale factor for test iterations */ | 78 int szTest; /* Scale factor for test iterations */ |
| 79 int nRepeat; /* Repeat selects this many times */ |
73 const char *zWR; /* Might be WITHOUT ROWID */ | 80 const char *zWR; /* Might be WITHOUT ROWID */ |
74 const char *zNN; /* Might be NOT NULL */ | 81 const char *zNN; /* Might be NOT NULL */ |
75 const char *zPK; /* Might be UNIQUE or PRIMARY KEY */ | 82 const char *zPK; /* Might be UNIQUE or PRIMARY KEY */ |
76 unsigned int x, y; /* Pseudo-random number generator state */ | 83 unsigned int x, y; /* Pseudo-random number generator state */ |
77 int nResult; /* Size of the current result */ | 84 int nResult; /* Size of the current result */ |
78 char zResult[3000]; /* Text of the current result */ | 85 char zResult[3000]; /* Text of the current result */ |
79 } g; | 86 } g; |
80 | 87 |
| 88 /* Return " TEMP" or "", as appropriate for creating a table. |
| 89 */ |
| 90 static const char *isTemp(int N){ |
| 91 return g.eTemp>=N ? " TEMP" : ""; |
| 92 } |
| 93 |
81 | 94 |
82 /* Print an error message and exit */ | 95 /* Print an error message and exit */ |
83 static void fatal_error(const char *zMsg, ...){ | 96 static void fatal_error(const char *zMsg, ...){ |
84 va_list ap; | 97 va_list ap; |
85 va_start(ap, zMsg); | 98 va_start(ap, zMsg); |
86 vfprintf(stderr, zMsg, ap); | 99 vfprintf(stderr, zMsg, ap); |
87 va_end(ap); | 100 va_end(ap); |
88 exit(1); | 101 exit(1); |
89 } | 102 } |
90 | 103 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 sqlite3_finalize(g.pStmt); | 419 sqlite3_finalize(g.pStmt); |
407 g.pStmt = pNew; | 420 g.pStmt = pNew; |
408 }else | 421 }else |
409 #endif | 422 #endif |
410 { | 423 { |
411 sqlite3_reset(g.pStmt); | 424 sqlite3_reset(g.pStmt); |
412 } | 425 } |
413 speedtest1_shrink_memory(); | 426 speedtest1_shrink_memory(); |
414 } | 427 } |
415 | 428 |
| 429 #ifndef SQLITE_OMIT_DEPRECATED |
416 /* The sqlite3_trace() callback function */ | 430 /* The sqlite3_trace() callback function */ |
417 static void traceCallback(void *NotUsed, const char *zSql){ | 431 static void traceCallback(void *NotUsed, const char *zSql){ |
418 int n = (int)strlen(zSql); | 432 int n = (int)strlen(zSql); |
419 while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--; | 433 while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--; |
420 fprintf(stderr,"%.*s;\n", n, zSql); | 434 fprintf(stderr,"%.*s;\n", n, zSql); |
421 } | 435 } |
| 436 #endif /* SQLITE_OMIT_DEPRECATED */ |
422 | 437 |
423 /* Substitute random() function that gives the same random | 438 /* Substitute random() function that gives the same random |
424 ** sequence on each run, for repeatability. */ | 439 ** sequence on each run, for repeatability. */ |
425 static void randomFunc( | 440 static void randomFunc( |
426 sqlite3_context *context, | 441 sqlite3_context *context, |
427 int NotUsed, | 442 int NotUsed, |
428 sqlite3_value **NotUsed2 | 443 sqlite3_value **NotUsed2 |
429 ){ | 444 ){ |
430 sqlite3_result_int64(context, (sqlite3_int64)speedtest1_random()); | 445 sqlite3_result_int64(context, (sqlite3_int64)speedtest1_random()); |
431 } | 446 } |
432 | 447 |
433 /* Estimate the square root of an integer */ | 448 /* Estimate the square root of an integer */ |
434 static int est_square_root(int x){ | 449 static int est_square_root(int x){ |
435 int y0 = x/2; | 450 int y0 = x/2; |
436 int y1; | 451 int y1; |
437 int n; | 452 int n; |
438 for(n=0; y0>0 && n<10; n++){ | 453 for(n=0; y0>0 && n<10; n++){ |
439 y1 = (y0 + x/y0)/2; | 454 y1 = (y0 + x/y0)/2; |
440 if( y1==y0 ) break; | 455 if( y1==y0 ) break; |
441 y0 = y1; | 456 y0 = y1; |
442 } | 457 } |
443 return y0; | 458 return y0; |
444 } | 459 } |
445 | 460 |
| 461 |
| 462 #if SQLITE_VERSION_NUMBER<3005004 |
| 463 /* |
| 464 ** An implementation of group_concat(). Used only when testing older |
| 465 ** versions of SQLite that lack the built-in group_concat(). |
| 466 */ |
| 467 struct groupConcat { |
| 468 char *z; |
| 469 int nAlloc; |
| 470 int nUsed; |
| 471 }; |
| 472 static void groupAppend(struct groupConcat *p, const char *z, int n){ |
| 473 if( p->nUsed+n >= p->nAlloc ){ |
| 474 int n2 = (p->nAlloc+n+1)*2; |
| 475 char *z2 = sqlite3_realloc(p->z, n2); |
| 476 if( z2==0 ) return; |
| 477 p->z = z2; |
| 478 p->nAlloc = n2; |
| 479 } |
| 480 memcpy(p->z+p->nUsed, z, n); |
| 481 p->nUsed += n; |
| 482 } |
| 483 static void groupStep( |
| 484 sqlite3_context *context, |
| 485 int argc, |
| 486 sqlite3_value **argv |
| 487 ){ |
| 488 const char *zVal; |
| 489 struct groupConcat *p; |
| 490 const char *zSep; |
| 491 int nVal, nSep; |
| 492 assert( argc==1 || argc==2 ); |
| 493 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; |
| 494 p= (struct groupConcat*)sqlite3_aggregate_context(context, sizeof(*p)); |
| 495 |
| 496 if( p ){ |
| 497 int firstTerm = p->nUsed==0; |
| 498 if( !firstTerm ){ |
| 499 if( argc==2 ){ |
| 500 zSep = (char*)sqlite3_value_text(argv[1]); |
| 501 nSep = sqlite3_value_bytes(argv[1]); |
| 502 }else{ |
| 503 zSep = ","; |
| 504 nSep = 1; |
| 505 } |
| 506 if( nSep ) groupAppend(p, zSep, nSep); |
| 507 } |
| 508 zVal = (char*)sqlite3_value_text(argv[0]); |
| 509 nVal = sqlite3_value_bytes(argv[0]); |
| 510 if( zVal ) groupAppend(p, zVal, nVal); |
| 511 } |
| 512 } |
| 513 static void groupFinal(sqlite3_context *context){ |
| 514 struct groupConcat *p; |
| 515 p = sqlite3_aggregate_context(context, 0); |
| 516 if( p && p->z ){ |
| 517 p->z[p->nUsed] = 0; |
| 518 sqlite3_result_text(context, p->z, p->nUsed, sqlite3_free); |
| 519 } |
| 520 } |
| 521 #endif |
| 522 |
446 /* | 523 /* |
447 ** The main and default testset | 524 ** The main and default testset |
448 */ | 525 */ |
449 void testset_main(void){ | 526 void testset_main(void){ |
450 int i; /* Loop counter */ | 527 int i; /* Loop counter */ |
451 int n; /* iteration count */ | 528 int n; /* iteration count */ |
452 int sz; /* Size of the tables */ | 529 int sz; /* Size of the tables */ |
453 int maxb; /* Maximum swizzled value */ | 530 int maxb; /* Maximum swizzled value */ |
454 unsigned x1, x2; /* Parameters */ | 531 unsigned x1 = 0, x2 = 0; /* Parameters */ |
455 int len; /* Length of the zNum[] string */ | 532 int len = 0; /* Length of the zNum[] string */ |
456 char zNum[2000]; /* A number name */ | 533 char zNum[2000]; /* A number name */ |
457 | 534 |
458 sz = n = g.szTest*500; | 535 sz = n = g.szTest*500; |
| 536 zNum[0] = 0; |
459 maxb = roundup_allones(sz); | 537 maxb = roundup_allones(sz); |
460 speedtest1_begin_test(100, "%d INSERTs into table with no index", n); | 538 speedtest1_begin_test(100, "%d INSERTs into table with no index", n); |
461 speedtest1_exec("BEGIN"); | 539 speedtest1_exec("BEGIN"); |
462 speedtest1_exec("CREATE TABLE t1(a INTEGER %s, b INTEGER %s, c TEXT %s);", | 540 speedtest1_exec("CREATE%s TABLE t1(a INTEGER %s, b INTEGER %s, c TEXT %s);", |
463 g.zNN, g.zNN, g.zNN); | 541 isTemp(9), g.zNN, g.zNN, g.zNN); |
464 speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2,?3); -- %d times", n); | 542 speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2,?3); -- %d times", n); |
465 for(i=1; i<=n; i++){ | 543 for(i=1; i<=n; i++){ |
466 x1 = swizzle(i,maxb); | 544 x1 = swizzle(i,maxb); |
467 speedtest1_numbername(x1, zNum, sizeof(zNum)); | 545 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
468 sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); | 546 sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); |
469 sqlite3_bind_int(g.pStmt, 2, i); | 547 sqlite3_bind_int(g.pStmt, 2, i); |
470 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); | 548 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); |
471 speedtest1_run(); | 549 speedtest1_run(); |
472 } | 550 } |
473 speedtest1_exec("COMMIT"); | 551 speedtest1_exec("COMMIT"); |
474 speedtest1_end_test(); | 552 speedtest1_end_test(); |
475 | 553 |
476 | 554 |
477 n = sz; | 555 n = sz; |
478 speedtest1_begin_test(110, "%d ordered INSERTS with one index/PK", n); | 556 speedtest1_begin_test(110, "%d ordered INSERTS with one index/PK", n); |
479 speedtest1_exec("BEGIN"); | 557 speedtest1_exec("BEGIN"); |
480 speedtest1_exec("CREATE TABLE t2(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s"
, | 558 speedtest1_exec( |
481 g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); | 559 "CREATE%s TABLE t2(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s", |
| 560 isTemp(5), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); |
482 speedtest1_prepare("INSERT INTO t2 VALUES(?1,?2,?3); -- %d times", n); | 561 speedtest1_prepare("INSERT INTO t2 VALUES(?1,?2,?3); -- %d times", n); |
483 for(i=1; i<=n; i++){ | 562 for(i=1; i<=n; i++){ |
484 x1 = swizzle(i,maxb); | 563 x1 = swizzle(i,maxb); |
485 speedtest1_numbername(x1, zNum, sizeof(zNum)); | 564 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
486 sqlite3_bind_int(g.pStmt, 1, i); | 565 sqlite3_bind_int(g.pStmt, 1, i); |
487 sqlite3_bind_int64(g.pStmt, 2, (sqlite3_int64)x1); | 566 sqlite3_bind_int64(g.pStmt, 2, (sqlite3_int64)x1); |
488 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); | 567 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); |
489 speedtest1_run(); | 568 speedtest1_run(); |
490 } | 569 } |
491 speedtest1_exec("COMMIT"); | 570 speedtest1_exec("COMMIT"); |
492 speedtest1_end_test(); | 571 speedtest1_end_test(); |
493 | 572 |
494 | 573 |
495 n = sz; | 574 n = sz; |
496 speedtest1_begin_test(120, "%d unordered INSERTS with one index/PK", n); | 575 speedtest1_begin_test(120, "%d unordered INSERTS with one index/PK", n); |
497 speedtest1_exec("BEGIN"); | 576 speedtest1_exec("BEGIN"); |
498 speedtest1_exec("CREATE TABLE t3(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s"
, | 577 speedtest1_exec( |
499 g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); | 578 "CREATE%s TABLE t3(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s", |
| 579 isTemp(3), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); |
500 speedtest1_prepare("INSERT INTO t3 VALUES(?1,?2,?3); -- %d times", n); | 580 speedtest1_prepare("INSERT INTO t3 VALUES(?1,?2,?3); -- %d times", n); |
501 for(i=1; i<=n; i++){ | 581 for(i=1; i<=n; i++){ |
502 x1 = swizzle(i,maxb); | 582 x1 = swizzle(i,maxb); |
503 speedtest1_numbername(x1, zNum, sizeof(zNum)); | 583 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
504 sqlite3_bind_int(g.pStmt, 2, i); | 584 sqlite3_bind_int(g.pStmt, 2, i); |
505 sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); | 585 sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); |
506 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); | 586 sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); |
507 speedtest1_run(); | 587 speedtest1_run(); |
508 } | 588 } |
509 speedtest1_exec("COMMIT"); | 589 speedtest1_exec("COMMIT"); |
510 speedtest1_end_test(); | 590 speedtest1_end_test(); |
511 | 591 |
| 592 #if SQLITE_VERSION_NUMBER<3005004 |
| 593 sqlite3_create_function(g.db, "group_concat", 1, SQLITE_UTF8, 0, |
| 594 0, groupStep, groupFinal); |
| 595 #endif |
512 | 596 |
513 n = 25; | 597 n = 25; |
514 speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n); | 598 speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n); |
515 speedtest1_exec("BEGIN"); | 599 speedtest1_exec("BEGIN"); |
516 speedtest1_prepare( | 600 speedtest1_prepare( |
517 "SELECT count(*), avg(b), sum(length(c)) FROM t1\n" | 601 "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n" |
518 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n | 602 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n |
519 ); | 603 ); |
520 for(i=1; i<=n; i++){ | 604 for(i=1; i<=n; i++){ |
521 x1 = speedtest1_random()%maxb; | 605 if( (i-1)%g.nRepeat==0 ){ |
522 x2 = speedtest1_random()%10 + sz/5000 + x1; | 606 x1 = speedtest1_random()%maxb; |
| 607 x2 = speedtest1_random()%10 + sz/5000 + x1; |
| 608 } |
523 sqlite3_bind_int(g.pStmt, 1, x1); | 609 sqlite3_bind_int(g.pStmt, 1, x1); |
524 sqlite3_bind_int(g.pStmt, 2, x2); | 610 sqlite3_bind_int(g.pStmt, 2, x2); |
525 speedtest1_run(); | 611 speedtest1_run(); |
526 } | 612 } |
527 speedtest1_exec("COMMIT"); | 613 speedtest1_exec("COMMIT"); |
528 speedtest1_end_test(); | 614 speedtest1_end_test(); |
529 | 615 |
530 | 616 |
531 n = 10; | 617 n = 10; |
532 speedtest1_begin_test(140, "%d SELECTS, LIKE, unindexed", n); | 618 speedtest1_begin_test(140, "%d SELECTS, LIKE, unindexed", n); |
533 speedtest1_exec("BEGIN"); | 619 speedtest1_exec("BEGIN"); |
534 speedtest1_prepare( | 620 speedtest1_prepare( |
535 "SELECT count(*), avg(b), sum(length(c)) FROM t1\n" | 621 "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n" |
536 " WHERE c LIKE ?1; -- %d times", n | 622 " WHERE c LIKE ?1; -- %d times", n |
537 ); | 623 ); |
538 for(i=1; i<=n; i++){ | 624 for(i=1; i<=n; i++){ |
539 x1 = speedtest1_random()%maxb; | 625 if( (i-1)%g.nRepeat==0 ){ |
540 zNum[0] = '%'; | 626 x1 = speedtest1_random()%maxb; |
541 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); | 627 zNum[0] = '%'; |
542 zNum[len] = '%'; | 628 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); |
543 zNum[len+1] = 0; | 629 zNum[len] = '%'; |
544 sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); | 630 zNum[len+1] = 0; |
| 631 } |
| 632 sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC); |
545 speedtest1_run(); | 633 speedtest1_run(); |
546 } | 634 } |
547 speedtest1_exec("COMMIT"); | 635 speedtest1_exec("COMMIT"); |
548 speedtest1_end_test(); | 636 speedtest1_end_test(); |
549 | 637 |
550 | 638 |
551 n = 10; | 639 n = 10; |
552 speedtest1_begin_test(142, "%d SELECTS w/ORDER BY, unindexed", n); | 640 speedtest1_begin_test(142, "%d SELECTS w/ORDER BY, unindexed", n); |
553 speedtest1_exec("BEGIN"); | 641 speedtest1_exec("BEGIN"); |
554 speedtest1_prepare( | 642 speedtest1_prepare( |
555 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" | 643 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" |
556 " ORDER BY a; -- %d times", n | 644 " ORDER BY a; -- %d times", n |
557 ); | 645 ); |
558 for(i=1; i<=n; i++){ | 646 for(i=1; i<=n; i++){ |
559 x1 = speedtest1_random()%maxb; | 647 if( (i-1)%g.nRepeat==0 ){ |
560 zNum[0] = '%'; | 648 x1 = speedtest1_random()%maxb; |
561 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); | 649 zNum[0] = '%'; |
562 zNum[len] = '%'; | 650 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); |
563 zNum[len+1] = 0; | 651 zNum[len] = '%'; |
564 sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); | 652 zNum[len+1] = 0; |
| 653 } |
| 654 sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC); |
565 speedtest1_run(); | 655 speedtest1_run(); |
566 } | 656 } |
567 speedtest1_exec("COMMIT"); | 657 speedtest1_exec("COMMIT"); |
568 speedtest1_end_test(); | 658 speedtest1_end_test(); |
569 | 659 |
570 n = 10; /* g.szTest/5; */ | 660 n = 10; /* g.szTest/5; */ |
571 speedtest1_begin_test(145, "%d SELECTS w/ORDER BY and LIMIT, unindexed", n); | 661 speedtest1_begin_test(145, "%d SELECTS w/ORDER BY and LIMIT, unindexed", n); |
572 speedtest1_exec("BEGIN"); | 662 speedtest1_exec("BEGIN"); |
573 speedtest1_prepare( | 663 speedtest1_prepare( |
574 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" | 664 "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" |
575 " ORDER BY a LIMIT 10; -- %d times", n | 665 " ORDER BY a LIMIT 10; -- %d times", n |
576 ); | 666 ); |
577 for(i=1; i<=n; i++){ | 667 for(i=1; i<=n; i++){ |
578 x1 = speedtest1_random()%maxb; | 668 if( (i-1)%g.nRepeat==0 ){ |
579 zNum[0] = '%'; | 669 x1 = speedtest1_random()%maxb; |
580 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); | 670 zNum[0] = '%'; |
581 zNum[len] = '%'; | 671 len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); |
582 zNum[len+1] = 0; | 672 zNum[len] = '%'; |
583 sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); | 673 zNum[len+1] = 0; |
| 674 } |
| 675 sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC); |
584 speedtest1_run(); | 676 speedtest1_run(); |
585 } | 677 } |
586 speedtest1_exec("COMMIT"); | 678 speedtest1_exec("COMMIT"); |
587 speedtest1_end_test(); | 679 speedtest1_end_test(); |
588 | 680 |
589 | 681 |
590 speedtest1_begin_test(150, "CREATE INDEX five times"); | 682 speedtest1_begin_test(150, "CREATE INDEX five times"); |
591 speedtest1_exec("BEGIN;"); | 683 speedtest1_exec("BEGIN;"); |
592 speedtest1_exec("CREATE UNIQUE INDEX t1b ON t1(b);"); | 684 speedtest1_exec("CREATE UNIQUE INDEX t1b ON t1(b);"); |
593 speedtest1_exec("CREATE INDEX t1c ON t1(c);"); | 685 speedtest1_exec("CREATE INDEX t1c ON t1(c);"); |
594 speedtest1_exec("CREATE UNIQUE INDEX t2b ON t2(b);"); | 686 speedtest1_exec("CREATE UNIQUE INDEX t2b ON t2(b);"); |
595 speedtest1_exec("CREATE INDEX t2c ON t2(c DESC);"); | 687 speedtest1_exec("CREATE INDEX t2c ON t2(c DESC);"); |
596 speedtest1_exec("CREATE INDEX t3bc ON t3(b,c);"); | 688 speedtest1_exec("CREATE INDEX t3bc ON t3(b,c);"); |
597 speedtest1_exec("COMMIT;"); | 689 speedtest1_exec("COMMIT;"); |
598 speedtest1_end_test(); | 690 speedtest1_end_test(); |
599 | 691 |
600 | 692 |
601 n = sz/5; | 693 n = sz/5; |
602 speedtest1_begin_test(160, "%d SELECTS, numeric BETWEEN, indexed", n); | 694 speedtest1_begin_test(160, "%d SELECTS, numeric BETWEEN, indexed", n); |
603 speedtest1_exec("BEGIN"); | 695 speedtest1_exec("BEGIN"); |
604 speedtest1_prepare( | 696 speedtest1_prepare( |
605 "SELECT count(*), avg(b), sum(length(c)) FROM t1\n" | 697 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\n" |
606 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n | 698 " WHERE b BETWEEN ?1 AND ?2; -- %d times", n |
607 ); | 699 ); |
608 for(i=1; i<=n; i++){ | 700 for(i=1; i<=n; i++){ |
609 x1 = speedtest1_random()%maxb; | 701 if( (i-1)%g.nRepeat==0 ){ |
610 x2 = speedtest1_random()%10 + sz/5000 + x1; | 702 x1 = speedtest1_random()%maxb; |
| 703 x2 = speedtest1_random()%10 + sz/5000 + x1; |
| 704 } |
611 sqlite3_bind_int(g.pStmt, 1, x1); | 705 sqlite3_bind_int(g.pStmt, 1, x1); |
612 sqlite3_bind_int(g.pStmt, 2, x2); | 706 sqlite3_bind_int(g.pStmt, 2, x2); |
613 speedtest1_run(); | 707 speedtest1_run(); |
614 } | 708 } |
615 speedtest1_exec("COMMIT"); | 709 speedtest1_exec("COMMIT"); |
616 speedtest1_end_test(); | 710 speedtest1_end_test(); |
617 | 711 |
618 | 712 |
619 n = sz/5; | 713 n = sz/5; |
620 speedtest1_begin_test(161, "%d SELECTS, numeric BETWEEN, PK", n); | 714 speedtest1_begin_test(161, "%d SELECTS, numeric BETWEEN, PK", n); |
621 speedtest1_exec("BEGIN"); | 715 speedtest1_exec("BEGIN"); |
622 speedtest1_prepare( | 716 speedtest1_prepare( |
623 "SELECT count(*), avg(b), sum(length(c)) FROM t2\n" | 717 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t2\n" |
624 " WHERE a BETWEEN ?1 AND ?2; -- %d times", n | 718 " WHERE a BETWEEN ?1 AND ?2; -- %d times", n |
625 ); | 719 ); |
626 for(i=1; i<=n; i++){ | 720 for(i=1; i<=n; i++){ |
627 x1 = speedtest1_random()%maxb; | 721 if( (i-1)%g.nRepeat==0 ){ |
628 x2 = speedtest1_random()%10 + sz/5000 + x1; | 722 x1 = speedtest1_random()%maxb; |
| 723 x2 = speedtest1_random()%10 + sz/5000 + x1; |
| 724 } |
629 sqlite3_bind_int(g.pStmt, 1, x1); | 725 sqlite3_bind_int(g.pStmt, 1, x1); |
630 sqlite3_bind_int(g.pStmt, 2, x2); | 726 sqlite3_bind_int(g.pStmt, 2, x2); |
631 speedtest1_run(); | 727 speedtest1_run(); |
632 } | 728 } |
633 speedtest1_exec("COMMIT"); | 729 speedtest1_exec("COMMIT"); |
634 speedtest1_end_test(); | 730 speedtest1_end_test(); |
635 | 731 |
636 | 732 |
637 n = sz/5; | 733 n = sz/5; |
638 speedtest1_begin_test(170, "%d SELECTS, text BETWEEN, indexed", n); | 734 speedtest1_begin_test(170, "%d SELECTS, text BETWEEN, indexed", n); |
639 speedtest1_exec("BEGIN"); | 735 speedtest1_exec("BEGIN"); |
640 speedtest1_prepare( | 736 speedtest1_prepare( |
641 "SELECT count(*), avg(b), sum(length(c)) FROM t1\n" | 737 "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\n" |
642 " WHERE c BETWEEN ?1 AND (?1||'~'); -- %d times", n | 738 " WHERE c BETWEEN ?1 AND (?1||'~'); -- %d times", n |
643 ); | 739 ); |
644 for(i=1; i<=n; i++){ | 740 for(i=1; i<=n; i++){ |
645 x1 = swizzle(i, maxb); | 741 if( (i-1)%g.nRepeat==0 ){ |
646 len = speedtest1_numbername(x1, zNum, sizeof(zNum)-1); | 742 x1 = swizzle(i, maxb); |
| 743 len = speedtest1_numbername(x1, zNum, sizeof(zNum)-1); |
| 744 } |
647 sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); | 745 sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); |
648 speedtest1_run(); | 746 speedtest1_run(); |
649 } | 747 } |
650 speedtest1_exec("COMMIT"); | 748 speedtest1_exec("COMMIT"); |
651 speedtest1_end_test(); | 749 speedtest1_end_test(); |
652 | 750 |
653 n = sz; | 751 n = sz; |
654 speedtest1_begin_test(180, "%d INSERTS with three indexes", n); | 752 speedtest1_begin_test(180, "%d INSERTS with three indexes", n); |
655 speedtest1_exec("BEGIN"); | 753 speedtest1_exec("BEGIN"); |
656 speedtest1_exec( | 754 speedtest1_exec( |
657 "CREATE TABLE t4(\n" | 755 "CREATE%s TABLE t4(\n" |
658 " a INTEGER %s %s,\n" | 756 " a INTEGER %s %s,\n" |
659 " b INTEGER %s,\n" | 757 " b INTEGER %s,\n" |
660 " c TEXT %s\n" | 758 " c TEXT %s\n" |
661 ") %s", | 759 ") %s", |
662 g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); | 760 isTemp(1), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR); |
663 speedtest1_exec("CREATE INDEX t4b ON t4(b)"); | 761 speedtest1_exec("CREATE INDEX t4b ON t4(b)"); |
664 speedtest1_exec("CREATE INDEX t4c ON t4(c)"); | 762 speedtest1_exec("CREATE INDEX t4c ON t4(c)"); |
665 speedtest1_exec("INSERT INTO t4 SELECT * FROM t1"); | 763 speedtest1_exec("INSERT INTO t4 SELECT * FROM t1"); |
666 speedtest1_exec("COMMIT"); | 764 speedtest1_exec("COMMIT"); |
667 speedtest1_end_test(); | 765 speedtest1_end_test(); |
668 | 766 |
669 n = sz; | 767 n = sz; |
670 speedtest1_begin_test(190, "DELETE and REFILL one table", n); | 768 speedtest1_begin_test(190, "DELETE and REFILL one table", n); |
671 speedtest1_exec("DELETE FROM t2;"); | 769 speedtest1_exec("DELETE FROM t2;"); |
672 speedtest1_exec("INSERT INTO t2 SELECT * FROM t1;"); | 770 speedtest1_exec("INSERT INTO t2 SELECT * FROM t1;"); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 speedtest1_begin_test(320, "subquery in result set", n); | 893 speedtest1_begin_test(320, "subquery in result set", n); |
796 speedtest1_prepare( | 894 speedtest1_prepare( |
797 "SELECT sum(a), max(c),\n" | 895 "SELECT sum(a), max(c),\n" |
798 " avg((SELECT a FROM t2 WHERE 5+t2.b=t1.b) AND rowid<?1), max(c)\n" | 896 " avg((SELECT a FROM t2 WHERE 5+t2.b=t1.b) AND rowid<?1), max(c)\n" |
799 " FROM t1 WHERE rowid<?1;" | 897 " FROM t1 WHERE rowid<?1;" |
800 ); | 898 ); |
801 sqlite3_bind_int(g.pStmt, 1, est_square_root(g.szTest)*50); | 899 sqlite3_bind_int(g.pStmt, 1, est_square_root(g.szTest)*50); |
802 speedtest1_run(); | 900 speedtest1_run(); |
803 speedtest1_end_test(); | 901 speedtest1_end_test(); |
804 | 902 |
| 903 sz = n = g.szTest*700; |
| 904 zNum[0] = 0; |
| 905 maxb = roundup_allones(sz/3); |
| 906 speedtest1_begin_test(400, "%d REPLACE ops on an IPK", n); |
| 907 speedtest1_exec("BEGIN"); |
| 908 speedtest1_exec("CREATE%s TABLE t5(a INTEGER PRIMARY KEY, b %s);", |
| 909 isTemp(9), g.zNN); |
| 910 speedtest1_prepare("REPLACE INTO t5 VALUES(?1,?2); -- %d times",n); |
| 911 for(i=1; i<=n; i++){ |
| 912 x1 = swizzle(i,maxb); |
| 913 speedtest1_numbername(i, zNum, sizeof(zNum)); |
| 914 sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1); |
| 915 sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC); |
| 916 speedtest1_run(); |
| 917 } |
| 918 speedtest1_exec("COMMIT"); |
| 919 speedtest1_end_test(); |
| 920 speedtest1_begin_test(410, "%d SELECTS on an IPK", n); |
| 921 speedtest1_prepare("SELECT b FROM t5 WHERE a=?1; -- %d times",n); |
| 922 for(i=1; i<=n; i++){ |
| 923 x1 = swizzle(i,maxb); |
| 924 sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1); |
| 925 speedtest1_run(); |
| 926 } |
| 927 speedtest1_end_test(); |
| 928 |
| 929 sz = n = g.szTest*700; |
| 930 zNum[0] = 0; |
| 931 maxb = roundup_allones(sz/3); |
| 932 speedtest1_begin_test(500, "%d REPLACE on TEXT PK", n); |
| 933 speedtest1_exec("BEGIN"); |
| 934 speedtest1_exec("CREATE%s TABLE t6(a TEXT PRIMARY KEY, b %s)%s;", |
| 935 isTemp(9), g.zNN, |
| 936 sqlite3_libversion_number()>=3008002 ? "WITHOUT ROWID" : ""); |
| 937 speedtest1_prepare("REPLACE INTO t6 VALUES(?1,?2); -- %d times",n); |
| 938 for(i=1; i<=n; i++){ |
| 939 x1 = swizzle(i,maxb); |
| 940 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
| 941 sqlite3_bind_int(g.pStmt, 2, i); |
| 942 sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC); |
| 943 speedtest1_run(); |
| 944 } |
| 945 speedtest1_exec("COMMIT"); |
| 946 speedtest1_end_test(); |
| 947 speedtest1_begin_test(510, "%d SELECTS on a TEXT PK", n); |
| 948 speedtest1_prepare("SELECT b FROM t6 WHERE a=?1; -- %d times",n); |
| 949 for(i=1; i<=n; i++){ |
| 950 x1 = swizzle(i,maxb); |
| 951 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
| 952 sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC); |
| 953 speedtest1_run(); |
| 954 } |
| 955 speedtest1_end_test(); |
| 956 speedtest1_begin_test(520, "%d SELECT DISTINCT", n); |
| 957 speedtest1_exec("SELECT DISTINCT b FROM t5;"); |
| 958 speedtest1_exec("SELECT DISTINCT b FROM t6;"); |
| 959 speedtest1_end_test(); |
| 960 |
| 961 |
805 speedtest1_begin_test(980, "PRAGMA integrity_check"); | 962 speedtest1_begin_test(980, "PRAGMA integrity_check"); |
806 speedtest1_exec("PRAGMA integrity_check"); | 963 speedtest1_exec("PRAGMA integrity_check"); |
807 speedtest1_end_test(); | 964 speedtest1_end_test(); |
808 | 965 |
809 | 966 |
810 speedtest1_begin_test(990, "ANALYZE"); | 967 speedtest1_begin_test(990, "ANALYZE"); |
811 speedtest1_exec("ANALYZE"); | 968 speedtest1_exec("ANALYZE"); |
812 speedtest1_end_test(); | 969 speedtest1_end_test(); |
813 } | 970 } |
814 | 971 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 | 1171 |
1015 #ifdef SQLITE_ENABLE_RTREE | 1172 #ifdef SQLITE_ENABLE_RTREE |
1016 /* | 1173 /* |
1017 ** A testset for the R-Tree virtual table | 1174 ** A testset for the R-Tree virtual table |
1018 */ | 1175 */ |
1019 void testset_rtree(int p1, int p2){ | 1176 void testset_rtree(int p1, int p2){ |
1020 unsigned i, n; | 1177 unsigned i, n; |
1021 unsigned mxCoord; | 1178 unsigned mxCoord; |
1022 unsigned x0, x1, y0, y1, z0, z1; | 1179 unsigned x0, x1, y0, y1, z0, z1; |
1023 unsigned iStep; | 1180 unsigned iStep; |
1024 int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*100 ); | 1181 int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*500 ); |
1025 | 1182 |
1026 mxCoord = 15000; | 1183 mxCoord = 15000; |
1027 n = g.szTest*100; | 1184 n = g.szTest*500; |
1028 speedtest1_begin_test(100, "%d INSERTs into an r-tree", n); | 1185 speedtest1_begin_test(100, "%d INSERTs into an r-tree", n); |
1029 speedtest1_exec("BEGIN"); | 1186 speedtest1_exec("BEGIN"); |
1030 speedtest1_exec("CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)"); | 1187 speedtest1_exec("CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)"); |
1031 speedtest1_prepare("INSERT INTO rt1(id,x0,x1,y0,y1,z0,z1)" | 1188 speedtest1_prepare("INSERT INTO rt1(id,x0,x1,y0,y1,z0,z1)" |
1032 "VALUES(?1,?2,?3,?4,?5,?6,?7)"); | 1189 "VALUES(?1,?2,?3,?4,?5,?6,?7)"); |
1033 for(i=1; i<=n; i++){ | 1190 for(i=1; i<=n; i++){ |
1034 twoCoords(p1, p2, mxCoord, &x0, &x1); | 1191 twoCoords(p1, p2, mxCoord, &x0, &x1); |
1035 twoCoords(p1, p2, mxCoord, &y0, &y1); | 1192 twoCoords(p1, p2, mxCoord, &y0, &y1); |
1036 twoCoords(p1, p2, mxCoord, &z0, &z1); | 1193 twoCoords(p1, p2, mxCoord, &z0, &z1); |
1037 sqlite3_bind_int(g.pStmt, 1, i); | 1194 sqlite3_bind_int(g.pStmt, 1, i); |
1038 sqlite3_bind_int(g.pStmt, 2, x0); | 1195 sqlite3_bind_int(g.pStmt, 2, x0); |
1039 sqlite3_bind_int(g.pStmt, 3, x1); | 1196 sqlite3_bind_int(g.pStmt, 3, x1); |
1040 sqlite3_bind_int(g.pStmt, 4, y0); | 1197 sqlite3_bind_int(g.pStmt, 4, y0); |
1041 sqlite3_bind_int(g.pStmt, 5, y1); | 1198 sqlite3_bind_int(g.pStmt, 5, y1); |
1042 sqlite3_bind_int(g.pStmt, 6, z0); | 1199 sqlite3_bind_int(g.pStmt, 6, z0); |
1043 sqlite3_bind_int(g.pStmt, 7, z1); | 1200 sqlite3_bind_int(g.pStmt, 7, z1); |
1044 speedtest1_run(); | 1201 speedtest1_run(); |
1045 } | 1202 } |
1046 speedtest1_exec("COMMIT"); | 1203 speedtest1_exec("COMMIT"); |
1047 speedtest1_end_test(); | 1204 speedtest1_end_test(); |
1048 | 1205 |
1049 speedtest1_begin_test(101, "Copy from rtree to a regular table"); | 1206 speedtest1_begin_test(101, "Copy from rtree to a regular table"); |
1050 speedtest1_exec("CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)"); | 1207 speedtest1_exec("CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)"); |
1051 speedtest1_exec("INSERT INTO t1 SELECT * FROM rt1"); | 1208 speedtest1_exec("INSERT INTO t1 SELECT * FROM rt1"); |
1052 speedtest1_end_test(); | 1209 speedtest1_end_test(); |
1053 | 1210 |
1054 n = g.szTest*20; | 1211 n = g.szTest*100; |
1055 speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n); | 1212 speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n); |
1056 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2"); | 1213 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2"); |
1057 iStep = mxCoord/n; | 1214 iStep = mxCoord/n; |
1058 for(i=0; i<n; i++){ | 1215 for(i=0; i<n; i++){ |
1059 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1216 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1060 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1217 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1061 speedtest1_run(); | 1218 speedtest1_run(); |
1062 aCheck[i] = atoi(g.zResult); | 1219 aCheck[i] = atoi(g.zResult); |
1063 } | 1220 } |
1064 speedtest1_end_test(); | 1221 speedtest1_end_test(); |
1065 | 1222 |
1066 if( g.bVerify ){ | 1223 if( g.bVerify ){ |
1067 n = g.szTest*20; | 1224 n = g.szTest*100; |
1068 speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries")
; | 1225 speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries")
; |
1069 speedtest1_prepare("SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2"); | 1226 speedtest1_prepare("SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2"); |
1070 iStep = mxCoord/n; | 1227 iStep = mxCoord/n; |
1071 for(i=0; i<n; i++){ | 1228 for(i=0; i<n; i++){ |
1072 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1229 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1073 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1230 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1074 speedtest1_run(); | 1231 speedtest1_run(); |
1075 if( aCheck[i]!=atoi(g.zResult) ){ | 1232 if( aCheck[i]!=atoi(g.zResult) ){ |
1076 fatal_error("Count disagree step %d: %d..%d. %d vs %d", | 1233 fatal_error("Count disagree step %d: %d..%d. %d vs %d", |
1077 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); | 1234 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); |
1078 } | 1235 } |
1079 } | 1236 } |
1080 speedtest1_end_test(); | 1237 speedtest1_end_test(); |
1081 } | 1238 } |
1082 | 1239 |
1083 n = g.szTest*20; | 1240 n = g.szTest*100; |
1084 speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n); | 1241 speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n); |
1085 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2"); | 1242 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2"); |
1086 iStep = mxCoord/n; | 1243 iStep = mxCoord/n; |
1087 for(i=0; i<n; i++){ | 1244 for(i=0; i<n; i++){ |
1088 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1245 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1089 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1246 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1090 speedtest1_run(); | 1247 speedtest1_run(); |
1091 aCheck[i] = atoi(g.zResult); | 1248 aCheck[i] = atoi(g.zResult); |
1092 } | 1249 } |
1093 speedtest1_end_test(); | 1250 speedtest1_end_test(); |
1094 | 1251 |
1095 if( g.bVerify ){ | 1252 if( g.bVerify ){ |
1096 n = g.szTest*20; | 1253 n = g.szTest*100; |
1097 speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries"); | 1254 speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries"); |
1098 speedtest1_prepare("SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2"); | 1255 speedtest1_prepare("SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2"); |
1099 iStep = mxCoord/n; | 1256 iStep = mxCoord/n; |
1100 for(i=0; i<n; i++){ | 1257 for(i=0; i<n; i++){ |
1101 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1258 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1102 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1259 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1103 speedtest1_run(); | 1260 speedtest1_run(); |
1104 if( aCheck[i]!=atoi(g.zResult) ){ | 1261 if( aCheck[i]!=atoi(g.zResult) ){ |
1105 fatal_error("Count disagree step %d: %d..%d. %d vs %d", | 1262 fatal_error("Count disagree step %d: %d..%d. %d vs %d", |
1106 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); | 1263 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); |
1107 } | 1264 } |
1108 } | 1265 } |
1109 speedtest1_end_test(); | 1266 speedtest1_end_test(); |
1110 } | 1267 } |
1111 | 1268 |
1112 | 1269 |
1113 n = g.szTest*20; | 1270 n = g.szTest*100; |
1114 speedtest1_begin_test(125, "%d custom geometry callback queries", n); | 1271 speedtest1_begin_test(125, "%d custom geometry callback queries", n); |
1115 sqlite3_rtree_geometry_callback(g.db, "xslice", xsliceGeometryCallback, 0); | 1272 sqlite3_rtree_geometry_callback(g.db, "xslice", xsliceGeometryCallback, 0); |
1116 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)"); | 1273 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)"); |
1117 iStep = mxCoord/n; | 1274 iStep = mxCoord/n; |
1118 for(i=0; i<n; i++){ | 1275 for(i=0; i<n; i++){ |
1119 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1276 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1120 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1277 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1121 speedtest1_run(); | 1278 speedtest1_run(); |
1122 if( aCheck[i]!=atoi(g.zResult) ){ | 1279 if( aCheck[i]!=atoi(g.zResult) ){ |
1123 fatal_error("Count disagree step %d: %d..%d. %d vs %d", | 1280 fatal_error("Count disagree step %d: %d..%d. %d vs %d", |
1124 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); | 1281 i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult)); |
1125 } | 1282 } |
1126 } | 1283 } |
1127 speedtest1_end_test(); | 1284 speedtest1_end_test(); |
1128 | 1285 |
1129 n = g.szTest*80; | 1286 n = g.szTest*400; |
1130 speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n); | 1287 speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n); |
1131 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2" | 1288 speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2" |
1132 " AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2"); | 1289 " AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2"); |
1133 iStep = mxCoord/n; | 1290 iStep = mxCoord/n; |
1134 for(i=0; i<n; i++){ | 1291 for(i=0; i<n; i++){ |
1135 sqlite3_bind_int(g.pStmt, 1, i*iStep); | 1292 sqlite3_bind_int(g.pStmt, 1, i*iStep); |
1136 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); | 1293 sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep); |
1137 speedtest1_run(); | 1294 speedtest1_run(); |
1138 aCheck[i] = atoi(g.zResult); | 1295 aCheck[i] = atoi(g.zResult); |
1139 } | 1296 } |
1140 speedtest1_end_test(); | 1297 speedtest1_end_test(); |
1141 | 1298 |
1142 n = g.szTest*100; | 1299 n = g.szTest*500; |
1143 speedtest1_begin_test(140, "%d rowid queries", n); | 1300 speedtest1_begin_test(140, "%d rowid queries", n); |
1144 speedtest1_prepare("SELECT * FROM rt1 WHERE id=?1"); | 1301 speedtest1_prepare("SELECT * FROM rt1 WHERE id=?1"); |
1145 for(i=1; i<=n; i++){ | 1302 for(i=1; i<=n; i++){ |
1146 sqlite3_bind_int(g.pStmt, 1, i); | 1303 sqlite3_bind_int(g.pStmt, 1, i); |
1147 speedtest1_run(); | 1304 speedtest1_run(); |
1148 } | 1305 } |
1149 speedtest1_end_test(); | 1306 speedtest1_end_test(); |
1150 } | 1307 } |
1151 #endif /* SQLITE_ENABLE_RTREE */ | 1308 #endif /* SQLITE_ENABLE_RTREE */ |
1152 | 1309 |
1153 /* | 1310 /* |
1154 ** A testset used for debugging speedtest1 itself. | 1311 ** A testset used for debugging speedtest1 itself. |
1155 */ | 1312 */ |
1156 void testset_debug1(void){ | 1313 void testset_debug1(void){ |
1157 unsigned i, n; | 1314 unsigned i, n; |
1158 unsigned x1, x2; | 1315 unsigned x1, x2; |
1159 char zNum[2000]; /* A number name */ | 1316 char zNum[2000]; /* A number name */ |
1160 | 1317 |
1161 n = g.szTest; | 1318 n = g.szTest; |
1162 for(i=1; i<=n; i++){ | 1319 for(i=1; i<=n; i++){ |
1163 x1 = swizzle(i, n); | 1320 x1 = swizzle(i, n); |
1164 x2 = swizzle(x1, n); | 1321 x2 = swizzle(x1, n); |
1165 speedtest1_numbername(x1, zNum, sizeof(zNum)); | 1322 speedtest1_numbername(x1, zNum, sizeof(zNum)); |
1166 printf("%5d %5d %5d %s\n", i, x1, x2, zNum); | 1323 printf("%5d %5d %5d %s\n", i, x1, x2, zNum); |
1167 } | 1324 } |
1168 } | 1325 } |
1169 | 1326 |
| 1327 #ifdef __linux__ |
| 1328 #include <sys/types.h> |
| 1329 #include <unistd.h> |
| 1330 |
| 1331 /* |
| 1332 ** Attempt to display I/O stats on Linux using /proc/PID/io |
| 1333 */ |
| 1334 static void displayLinuxIoStats(FILE *out){ |
| 1335 FILE *in; |
| 1336 char z[200]; |
| 1337 sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid()); |
| 1338 in = fopen(z, "rb"); |
| 1339 if( in==0 ) return; |
| 1340 while( fgets(z, sizeof(z), in)!=0 ){ |
| 1341 static const struct { |
| 1342 const char *zPattern; |
| 1343 const char *zDesc; |
| 1344 } aTrans[] = { |
| 1345 { "rchar: ", "Bytes received by read():" }, |
| 1346 { "wchar: ", "Bytes sent to write():" }, |
| 1347 { "syscr: ", "Read() system calls:" }, |
| 1348 { "syscw: ", "Write() system calls:" }, |
| 1349 { "read_bytes: ", "Bytes rcvd from storage:" }, |
| 1350 { "write_bytes: ", "Bytes sent to storage:" }, |
| 1351 { "cancelled_write_bytes: ", "Cancelled write bytes:" }, |
| 1352 }; |
| 1353 int i; |
| 1354 for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){ |
| 1355 int n = (int)strlen(aTrans[i].zPattern); |
| 1356 if( strncmp(aTrans[i].zPattern, z, n)==0 ){ |
| 1357 fprintf(out, "-- %-28s %s", aTrans[i].zDesc, &z[n]); |
| 1358 break; |
| 1359 } |
| 1360 } |
| 1361 } |
| 1362 fclose(in); |
| 1363 } |
| 1364 #endif |
| 1365 |
| 1366 #if SQLITE_VERSION_NUMBER<3006018 |
| 1367 # define sqlite3_sourceid(X) "(before 3.6.18)" |
| 1368 #endif |
| 1369 |
1170 int main(int argc, char **argv){ | 1370 int main(int argc, char **argv){ |
1171 int doAutovac = 0; /* True for --autovacuum */ | 1371 int doAutovac = 0; /* True for --autovacuum */ |
1172 int cacheSize = 0; /* Desired cache size. 0 means default */ | 1372 int cacheSize = 0; /* Desired cache size. 0 means default */ |
1173 int doExclusive = 0; /* True for --exclusive */ | 1373 int doExclusive = 0; /* True for --exclusive */ |
1174 int nHeap = 0, mnHeap = 0; /* Heap size from --heap */ | 1374 int nHeap = 0, mnHeap = 0; /* Heap size from --heap */ |
1175 int doIncrvac = 0; /* True for --incrvacuum */ | 1375 int doIncrvac = 0; /* True for --incrvacuum */ |
1176 const char *zJMode = 0; /* Journal mode */ | 1376 const char *zJMode = 0; /* Journal mode */ |
1177 const char *zKey = 0; /* Encryption key */ | 1377 const char *zKey = 0; /* Encryption key */ |
1178 int nLook = 0, szLook = 0; /* --lookaside configuration */ | 1378 int nLook = -1, szLook = 0; /* --lookaside configuration */ |
1179 int noSync = 0; /* True for --nosync */ | 1379 int noSync = 0; /* True for --nosync */ |
1180 int pageSize = 0; /* Desired page size. 0 means default */ | 1380 int pageSize = 0; /* Desired page size. 0 means default */ |
1181 int nPCache = 0, szPCache = 0;/* --pcache configuration */ | 1381 int nPCache = 0, szPCache = 0;/* --pcache configuration */ |
1182 int doPCache = 0; /* True if --pcache is seen */ | 1382 int doPCache = 0; /* True if --pcache is seen */ |
1183 int nScratch = 0, szScratch=0;/* --scratch configuration */ | 1383 int nScratch = 0, szScratch=0;/* --scratch configuration */ |
1184 int showStats = 0; /* True for --stats */ | 1384 int showStats = 0; /* True for --stats */ |
1185 int nThread = 0; /* --threads value */ | 1385 int nThread = 0; /* --threads value */ |
| 1386 int mmapSize = 0; /* How big of a memory map to use */ |
1186 const char *zTSet = "main"; /* Which --testset torun */ | 1387 const char *zTSet = "main"; /* Which --testset torun */ |
1187 int doTrace = 0; /* True for --trace */ | 1388 int doTrace = 0; /* True for --trace */ |
1188 const char *zEncoding = 0; /* --utf16be or --utf16le */ | 1389 const char *zEncoding = 0; /* --utf16be or --utf16le */ |
1189 const char *zDbName = 0; /* Name of the test database */ | 1390 const char *zDbName = 0; /* Name of the test database */ |
1190 | 1391 |
1191 void *pHeap = 0; /* Allocated heap space */ | 1392 void *pHeap = 0; /* Allocated heap space */ |
1192 void *pLook = 0; /* Allocated lookaside space */ | 1393 void *pLook = 0; /* Allocated lookaside space */ |
1193 void *pPCache = 0; /* Allocated storage for pcache */ | 1394 void *pPCache = 0; /* Allocated storage for pcache */ |
1194 void *pScratch = 0; /* Allocated storage for scratch */ | 1395 void *pScratch = 0; /* Allocated storage for scratch */ |
1195 int iCur, iHi; /* Stats values, current and "highwater" */ | 1396 int iCur, iHi; /* Stats values, current and "highwater" */ |
1196 int i; /* Loop counter */ | 1397 int i; /* Loop counter */ |
1197 int rc; /* API return code */ | 1398 int rc; /* API return code */ |
1198 | 1399 |
| 1400 /* Display the version of SQLite being tested */ |
| 1401 printf("-- Speedtest1 for SQLite %s %.50s\n", |
| 1402 sqlite3_libversion(), sqlite3_sourceid()); |
| 1403 |
1199 /* Process command-line arguments */ | 1404 /* Process command-line arguments */ |
1200 g.zWR = ""; | 1405 g.zWR = ""; |
1201 g.zNN = ""; | 1406 g.zNN = ""; |
1202 g.zPK = "UNIQUE"; | 1407 g.zPK = "UNIQUE"; |
1203 g.szTest = 100; | 1408 g.szTest = 100; |
| 1409 g.nRepeat = 1; |
1204 for(i=1; i<argc; i++){ | 1410 for(i=1; i<argc; i++){ |
1205 const char *z = argv[i]; | 1411 const char *z = argv[i]; |
1206 if( z[0]=='-' ){ | 1412 if( z[0]=='-' ){ |
1207 do{ z++; }while( z[0]=='-' ); | 1413 do{ z++; }while( z[0]=='-' ); |
1208 if( strcmp(z,"autovacuum")==0 ){ | 1414 if( strcmp(z,"autovacuum")==0 ){ |
1209 doAutovac = 1; | 1415 doAutovac = 1; |
1210 }else if( strcmp(z,"cachesize")==0 ){ | 1416 }else if( strcmp(z,"cachesize")==0 ){ |
1211 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1417 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1212 i++; | 1418 i++; |
1213 cacheSize = integerValue(argv[i]); | 1419 cacheSize = integerValue(argv[i]); |
(...skipping 13 matching lines...) Expand all Loading... |
1227 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1433 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1228 zJMode = argv[++i]; | 1434 zJMode = argv[++i]; |
1229 }else if( strcmp(z,"key")==0 ){ | 1435 }else if( strcmp(z,"key")==0 ){ |
1230 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1436 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1231 zKey = argv[++i]; | 1437 zKey = argv[++i]; |
1232 }else if( strcmp(z,"lookaside")==0 ){ | 1438 }else if( strcmp(z,"lookaside")==0 ){ |
1233 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); | 1439 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); |
1234 nLook = integerValue(argv[i+1]); | 1440 nLook = integerValue(argv[i+1]); |
1235 szLook = integerValue(argv[i+2]); | 1441 szLook = integerValue(argv[i+2]); |
1236 i += 2; | 1442 i += 2; |
| 1443 #if SQLITE_VERSION_NUMBER>=3006000 |
1237 }else if( strcmp(z,"multithread")==0 ){ | 1444 }else if( strcmp(z,"multithread")==0 ){ |
1238 sqlite3_config(SQLITE_CONFIG_MULTITHREAD); | 1445 sqlite3_config(SQLITE_CONFIG_MULTITHREAD); |
1239 }else if( strcmp(z,"nomemstat")==0 ){ | 1446 }else if( strcmp(z,"nomemstat")==0 ){ |
1240 sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0); | 1447 sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0); |
| 1448 #endif |
| 1449 #if SQLITE_VERSION_NUMBER>=3007017 |
| 1450 }else if( strcmp(z, "mmap")==0 ){ |
| 1451 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
| 1452 mmapSize = integerValue(argv[++i]); |
| 1453 #endif |
1241 }else if( strcmp(z,"nosync")==0 ){ | 1454 }else if( strcmp(z,"nosync")==0 ){ |
1242 noSync = 1; | 1455 noSync = 1; |
1243 }else if( strcmp(z,"notnull")==0 ){ | 1456 }else if( strcmp(z,"notnull")==0 ){ |
1244 g.zNN = "NOT NULL"; | 1457 g.zNN = "NOT NULL"; |
1245 #ifdef SQLITE_ENABLE_RBU | |
1246 }else if( strcmp(z,"rbu")==0 ){ | |
1247 sqlite3ota_create_vfs("rbu", 0); | |
1248 sqlite3_vfs_register(sqlite3_vfs_find("rbu"), 1); | |
1249 #endif | |
1250 }else if( strcmp(z,"pagesize")==0 ){ | 1458 }else if( strcmp(z,"pagesize")==0 ){ |
1251 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1459 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1252 pageSize = integerValue(argv[++i]); | 1460 pageSize = integerValue(argv[++i]); |
1253 }else if( strcmp(z,"pcache")==0 ){ | 1461 }else if( strcmp(z,"pcache")==0 ){ |
1254 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); | 1462 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); |
1255 nPCache = integerValue(argv[i+1]); | 1463 nPCache = integerValue(argv[i+1]); |
1256 szPCache = integerValue(argv[i+2]); | 1464 szPCache = integerValue(argv[i+2]); |
1257 doPCache = 1; | 1465 doPCache = 1; |
1258 i += 2; | 1466 i += 2; |
1259 }else if( strcmp(z,"primarykey")==0 ){ | 1467 }else if( strcmp(z,"primarykey")==0 ){ |
1260 g.zPK = "PRIMARY KEY"; | 1468 g.zPK = "PRIMARY KEY"; |
| 1469 }else if( strcmp(z,"repeat")==0 ){ |
| 1470 if( i>=argc-1 ) fatal_error("missing arguments on %s\n", argv[i]); |
| 1471 g.nRepeat = integerValue(argv[i+1]); |
| 1472 i += 1; |
1261 }else if( strcmp(z,"reprepare")==0 ){ | 1473 }else if( strcmp(z,"reprepare")==0 ){ |
1262 g.bReprepare = 1; | 1474 g.bReprepare = 1; |
1263 }else if( strcmp(z,"scratch")==0 ){ | 1475 }else if( strcmp(z,"scratch")==0 ){ |
1264 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); | 1476 if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); |
1265 nScratch = integerValue(argv[i+1]); | 1477 nScratch = integerValue(argv[i+1]); |
1266 szScratch = integerValue(argv[i+2]); | 1478 szScratch = integerValue(argv[i+2]); |
1267 i += 2; | 1479 i += 2; |
| 1480 #if SQLITE_VERSION_NUMBER>=3006000 |
1268 }else if( strcmp(z,"serialized")==0 ){ | 1481 }else if( strcmp(z,"serialized")==0 ){ |
1269 sqlite3_config(SQLITE_CONFIG_SERIALIZED); | 1482 sqlite3_config(SQLITE_CONFIG_SERIALIZED); |
1270 }else if( strcmp(z,"singlethread")==0 ){ | 1483 }else if( strcmp(z,"singlethread")==0 ){ |
1271 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); | 1484 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); |
| 1485 #endif |
1272 }else if( strcmp(z,"sqlonly")==0 ){ | 1486 }else if( strcmp(z,"sqlonly")==0 ){ |
1273 g.bSqlOnly = 1; | 1487 g.bSqlOnly = 1; |
1274 }else if( strcmp(z,"shrink-memory")==0 ){ | 1488 }else if( strcmp(z,"shrink-memory")==0 ){ |
1275 g.bMemShrink = 1; | 1489 g.bMemShrink = 1; |
1276 }else if( strcmp(z,"size")==0 ){ | 1490 }else if( strcmp(z,"size")==0 ){ |
1277 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1491 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1278 g.szTest = integerValue(argv[++i]); | 1492 g.szTest = integerValue(argv[++i]); |
1279 }else if( strcmp(z,"stats")==0 ){ | 1493 }else if( strcmp(z,"stats")==0 ){ |
1280 showStats = 1; | 1494 showStats = 1; |
| 1495 }else if( strcmp(z,"temp")==0 ){ |
| 1496 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
| 1497 i++; |
| 1498 if( argv[i][0]<'0' || argv[i][0]>'9' || argv[i][1]!=0 ){ |
| 1499 fatal_error("argument to --temp should be integer between 0 and 9"); |
| 1500 } |
| 1501 g.eTemp = argv[i][0] - '0'; |
1281 }else if( strcmp(z,"testset")==0 ){ | 1502 }else if( strcmp(z,"testset")==0 ){ |
1282 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1503 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1283 zTSet = argv[++i]; | 1504 zTSet = argv[++i]; |
1284 }else if( strcmp(z,"trace")==0 ){ | 1505 }else if( strcmp(z,"trace")==0 ){ |
1285 doTrace = 1; | 1506 doTrace = 1; |
1286 }else if( strcmp(z,"threads")==0 ){ | 1507 }else if( strcmp(z,"threads")==0 ){ |
1287 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); | 1508 if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); |
1288 nThread = integerValue(argv[++i]); | 1509 nThread = integerValue(argv[++i]); |
1289 }else if( strcmp(z,"utf16le")==0 ){ | 1510 }else if( strcmp(z,"utf16le")==0 ){ |
1290 zEncoding = "utf16le"; | 1511 zEncoding = "utf16le"; |
(...skipping 11 matching lines...) Expand all Loading... |
1302 fatal_error("unknown option: %s\nUse \"%s -?\" for help\n", | 1523 fatal_error("unknown option: %s\nUse \"%s -?\" for help\n", |
1303 argv[i], argv[0]); | 1524 argv[i], argv[0]); |
1304 } | 1525 } |
1305 }else if( zDbName==0 ){ | 1526 }else if( zDbName==0 ){ |
1306 zDbName = argv[i]; | 1527 zDbName = argv[i]; |
1307 }else{ | 1528 }else{ |
1308 fatal_error("surplus argument: %s\nUse \"%s -?\" for help\n", | 1529 fatal_error("surplus argument: %s\nUse \"%s -?\" for help\n", |
1309 argv[i], argv[0]); | 1530 argv[i], argv[0]); |
1310 } | 1531 } |
1311 } | 1532 } |
1312 #if 0 | 1533 if( zDbName!=0 ) unlink(zDbName); |
1313 if( zDbName==0 ){ | |
1314 fatal_error(zHelp, argv[0]); | |
1315 } | |
1316 #endif | |
1317 #if SQLITE_VERSION_NUMBER>=3006001 | 1534 #if SQLITE_VERSION_NUMBER>=3006001 |
1318 if( nHeap>0 ){ | 1535 if( nHeap>0 ){ |
1319 pHeap = malloc( nHeap ); | 1536 pHeap = malloc( nHeap ); |
1320 if( pHeap==0 ) fatal_error("cannot allocate %d-byte heap\n", nHeap); | 1537 if( pHeap==0 ) fatal_error("cannot allocate %d-byte heap\n", nHeap); |
1321 rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap); | 1538 rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap); |
1322 if( rc ) fatal_error("heap configuration failed: %d\n", rc); | 1539 if( rc ) fatal_error("heap configuration failed: %d\n", rc); |
1323 } | 1540 } |
1324 if( doPCache ){ | 1541 if( doPCache ){ |
1325 if( nPCache>0 && szPCache>0 ){ | 1542 if( nPCache>0 && szPCache>0 ){ |
1326 pPCache = malloc( nPCache*(sqlite3_int64)szPCache ); | 1543 pPCache = malloc( nPCache*(sqlite3_int64)szPCache ); |
1327 if( pPCache==0 ) fatal_error("cannot allocate %lld-byte pcache\n", | 1544 if( pPCache==0 ) fatal_error("cannot allocate %lld-byte pcache\n", |
1328 nPCache*(sqlite3_int64)szPCache); | 1545 nPCache*(sqlite3_int64)szPCache); |
1329 } | 1546 } |
1330 rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, pPCache, szPCache, nPCache); | 1547 rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, pPCache, szPCache, nPCache); |
1331 if( rc ) fatal_error("pcache configuration failed: %d\n", rc); | 1548 if( rc ) fatal_error("pcache configuration failed: %d\n", rc); |
1332 } | 1549 } |
1333 if( nScratch>0 && szScratch>0 ){ | 1550 if( nScratch>0 && szScratch>0 ){ |
1334 pScratch = malloc( nScratch*(sqlite3_int64)szScratch ); | 1551 pScratch = malloc( nScratch*(sqlite3_int64)szScratch ); |
1335 if( pScratch==0 ) fatal_error("cannot allocate %lld-byte scratch\n", | 1552 if( pScratch==0 ) fatal_error("cannot allocate %lld-byte scratch\n", |
1336 nScratch*(sqlite3_int64)szScratch); | 1553 nScratch*(sqlite3_int64)szScratch); |
1337 rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, pScratch, szScratch, nScratch); | 1554 rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, pScratch, szScratch, nScratch); |
1338 if( rc ) fatal_error("scratch configuration failed: %d\n", rc); | 1555 if( rc ) fatal_error("scratch configuration failed: %d\n", rc); |
1339 } | 1556 } |
1340 if( nLook>0 ){ | 1557 if( nLook>=0 ){ |
1341 sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0); | 1558 sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0); |
1342 } | 1559 } |
1343 #endif | 1560 #endif |
1344 | 1561 |
1345 /* Open the database and the input file */ | 1562 /* Open the database and the input file */ |
1346 if( sqlite3_open(zDbName, &g.db) ){ | 1563 if( sqlite3_open(zDbName, &g.db) ){ |
1347 fatal_error("Cannot open database file: %s\n", zDbName); | 1564 fatal_error("Cannot open database file: %s\n", zDbName); |
1348 } | 1565 } |
1349 #if SQLITE_VERSION_NUMBER>=3006001 | 1566 #if SQLITE_VERSION_NUMBER>=3006001 |
1350 if( nLook>0 && szLook>0 ){ | 1567 if( nLook>0 && szLook>0 ){ |
1351 pLook = malloc( nLook*szLook ); | 1568 pLook = malloc( nLook*szLook ); |
1352 rc = sqlite3_db_config(g.db, SQLITE_DBCONFIG_LOOKASIDE, pLook, szLook,nLook)
; | 1569 rc = sqlite3_db_config(g.db, SQLITE_DBCONFIG_LOOKASIDE, pLook, szLook,nLook)
; |
1353 if( rc ) fatal_error("lookaside configuration failed: %d\n", rc); | 1570 if( rc ) fatal_error("lookaside configuration failed: %d\n", rc); |
1354 } | 1571 } |
1355 #endif | 1572 #endif |
1356 | 1573 |
1357 /* Set database connection options */ | 1574 /* Set database connection options */ |
1358 sqlite3_create_function(g.db, "random", 0, SQLITE_UTF8, 0, randomFunc, 0, 0); | 1575 sqlite3_create_function(g.db, "random", 0, SQLITE_UTF8, 0, randomFunc, 0, 0); |
| 1576 #ifndef SQLITE_OMIT_DEPRECATED |
1359 if( doTrace ) sqlite3_trace(g.db, traceCallback, 0); | 1577 if( doTrace ) sqlite3_trace(g.db, traceCallback, 0); |
| 1578 #endif |
| 1579 if( mmapSize>0 ){ |
| 1580 speedtest1_exec("PRAGMA mmap_size=%d", mmapSize); |
| 1581 } |
1360 speedtest1_exec("PRAGMA threads=%d", nThread); | 1582 speedtest1_exec("PRAGMA threads=%d", nThread); |
1361 if( zKey ){ | 1583 if( zKey ){ |
1362 speedtest1_exec("PRAGMA key('%s')", zKey); | 1584 speedtest1_exec("PRAGMA key('%s')", zKey); |
1363 } | 1585 } |
1364 if( zEncoding ){ | 1586 if( zEncoding ){ |
1365 speedtest1_exec("PRAGMA encoding=%s", zEncoding); | 1587 speedtest1_exec("PRAGMA encoding=%s", zEncoding); |
1366 } | 1588 } |
1367 if( doAutovac ){ | 1589 if( doAutovac ){ |
1368 speedtest1_exec("PRAGMA auto_vacuum=FULL"); | 1590 speedtest1_exec("PRAGMA auto_vacuum=FULL"); |
1369 }else if( doIncrvac ){ | 1591 }else if( doIncrvac ){ |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 printf("-- Scratch Overflow Bytes: %d (max %d)\n", iCur,iHi); | 1672 printf("-- Scratch Overflow Bytes: %d (max %d)\n", iCur,iHi); |
1451 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0); | 1673 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0); |
1452 printf("-- Largest Allocation: %d bytes\n",iHi); | 1674 printf("-- Largest Allocation: %d bytes\n",iHi); |
1453 sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0); | 1675 sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0); |
1454 printf("-- Largest Pcache Allocation: %d bytes\n",iHi); | 1676 printf("-- Largest Pcache Allocation: %d bytes\n",iHi); |
1455 sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHi, 0); | 1677 sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHi, 0); |
1456 printf("-- Largest Scratch Allocation: %d bytes\n", iHi); | 1678 printf("-- Largest Scratch Allocation: %d bytes\n", iHi); |
1457 } | 1679 } |
1458 #endif | 1680 #endif |
1459 | 1681 |
| 1682 #ifdef __linux__ |
| 1683 if( showStats ){ |
| 1684 displayLinuxIoStats(stdout); |
| 1685 } |
| 1686 #endif |
| 1687 |
1460 /* Release memory */ | 1688 /* Release memory */ |
1461 free( pLook ); | 1689 free( pLook ); |
1462 free( pPCache ); | 1690 free( pPCache ); |
1463 free( pScratch ); | 1691 free( pScratch ); |
1464 free( pHeap ); | 1692 free( pHeap ); |
1465 return 0; | 1693 return 0; |
1466 } | 1694 } |
OLD | NEW |