diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 15 | ||||
-rw-r--r-- | src/btree.h | 6 | ||||
-rw-r--r-- | src/btreeInt.h | 3 | ||||
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/shell.c.in | 10 | ||||
-rw-r--r-- | src/sqlite.h.in | 1 |
6 files changed, 52 insertions, 1 deletions
diff --git a/src/btree.c b/src/btree.c index 457912169..ff05c7726 100644 --- a/src/btree.c +++ b/src/btree.c @@ -112,6 +112,17 @@ int sqlite3_enable_shared_cache(int enable){ #define hasReadConflicts(a, b) 0 #endif +#ifdef SQLITE_DEBUG +/* +** Return an reset the seek counter for a Btree object. +*/ +sqlite3_uint64 sqlite3BtreeSeekCount(Btree *pBt){ + u64 n = pBt->nSeek; + pBt->nSeek = 0; + return n; +} +#endif + /* ** Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single ** (MemPage*) as an argument. The (MemPage*) must not be NULL. @@ -5459,6 +5470,10 @@ int sqlite3BtreeMovetoUnpacked( } } +#ifdef SQLITE_DEBUG + pCur->pBtree->nSeek++; /* Performance measurement during testing */ +#endif + if( pIdxKey ){ xRecordCompare = sqlite3VdbeFindCompare(pIdxKey); pIdxKey->errCode = 0; diff --git a/src/btree.h b/src/btree.h index 4763ee04c..4cfa68585 100644 --- a/src/btree.h +++ b/src/btree.h @@ -330,6 +330,12 @@ int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask); int sqlite3BtreeIsReadonly(Btree *pBt); int sqlite3HeaderSizeBtree(void); +#ifdef SQLITE_DEBUG +sqlite3_uint64 sqlite3BtreeSeekCount(Btree*); +#else +# define sqlite3BtreeSeekCount(X) 0 +#endif + #ifndef NDEBUG int sqlite3BtreeCursorIsValid(BtCursor*); #endif diff --git a/src/btreeInt.h b/src/btreeInt.h index bffe09b61..c09699fbb 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -353,6 +353,9 @@ struct Btree { u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */ Btree *pNext; /* List of other sharable Btrees from the same db */ Btree *pPrev; /* Back pointer of the same list */ +#ifdef SQLITE_DEBUG + u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */ +#endif #ifndef SQLITE_OMIT_SHARED_CACHE BtLock lock; /* Object used to lock page 1 */ #endif diff --git a/src/main.c b/src/main.c index 917028c7b..18deb1299 100644 --- a/src/main.c +++ b/src/main.c @@ -4235,6 +4235,24 @@ int sqlite3_test_control(int op, ...){ sqlite3ResultIntReal(pCtx); break; } + + /* sqlite3_test_control(SQLITE_TESTCTRL_SEEK_COUNT, + ** sqlite3 *db, // Database connection + ** u64 *pnSeek // Write seek count here + ** ); + ** + ** This test-control queries the seek-counter on the "main" database + ** file. The seek-counter is written into *pnSeek and is then reset. + ** The seek-count is only available if compiled with SQLITE_DEBUG. + */ + case SQLITE_TESTCTRL_SEEK_COUNT: { + sqlite3 *db = va_arg(ap, sqlite3*); + u64 *pn = va_arg(ap, sqlite3_uint64*); + *pn = sqlite3BtreeSeekCount(db->aDb->pBt); + break; + } + + } va_end(ap); #endif /* SQLITE_UNTESTABLE */ diff --git a/src/shell.c.in b/src/shell.c.in index addd9779b..dcaff9161 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -9873,6 +9873,7 @@ static int do_meta_command(char *zLine, ShellState *p){ { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" }, { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" }, { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" }, + { "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" }, }; int testctrl = -1; int iCtrl = -1; @@ -9935,7 +9936,6 @@ static int do_meta_command(char *zLine, ShellState *p){ /* sqlite3_test_control(int) */ case SQLITE_TESTCTRL_PRNG_SAVE: case SQLITE_TESTCTRL_PRNG_RESTORE: - case SQLITE_TESTCTRL_PRNG_RESET: case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ rc2 = sqlite3_test_control(testctrl); @@ -10009,6 +10009,14 @@ static int do_meta_command(char *zLine, ShellState *p){ } break; + case SQLITE_TESTCTRL_SEEK_COUNT: { + u64 x = 0; + rc2 = sqlite3_test_control(testctrl, p->db, &x); + utf8_printf(p->out, "%llu\n", x); + isOk = 3; + break; + } + #ifdef YYCOVERAGE case SQLITE_TESTCTRL_PARSER_COVERAGE: if( nArg==2 ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9a372d32b..2a8ad56ce 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7739,6 +7739,7 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ +#define SQLITE_TESTCTRL_SEEK_COUNT 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |