1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Add the --mmap option to the kvtest utility program.

FossilOrigin-Name: 4948f7e6d2a1cfce36a7aab2f5b65be07c285ac3
This commit is contained in:
drh
2017-01-23 18:40:15 +00:00
parent 6aabff38e9
commit bace324082
3 changed files with 16 additions and 8 deletions

View File

@ -513,6 +513,7 @@ static int runMain(int argc, char **argv){
sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */
sqlite3_int64 tmStart; /* Start time */
sqlite3_int64 tmElapsed; /* Elapsed time */
int mmapSize = 0; /* --mmap N argument */
int nData = 0; /* Bytes of data */
sqlite3_int64 nTotal = 0; /* Total data read */
unsigned char *pData = 0; /* Content of the blob */
@ -535,6 +536,12 @@ static int runMain(int argc, char **argv){
if( nCount<1 ) fatalError("the --count must be positive");
continue;
}
if( strcmp(z, "-mmap")==0 ){
if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
mmapSize = atoi(argv[++i]);
if( nCount<0 ) fatalError("the --mmap must be non-negative");
continue;
}
if( strcmp(z, "-max-id")==0 ){
if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
iMax = atoi(argv[++i]);
@ -581,6 +588,8 @@ static int runMain(int argc, char **argv){
if( rc ){
fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
}
zSql = sqlite3_mprintf("PRAGMA mmap_size=%d", mmapSize);
sqlite3_exec(db, zSql, 0, 0, 0);
zSql = sqlite3_mprintf("PRAGMA cache_size=%d", iCache);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);