Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improved option handling in speedtest8.c. Added -quiet and -priority options. Added reporting of total user and system time. (CVS 5070) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
aa59974ec15508d69c5b65ab89ec7bc3 |
User & Date: | shane 2008-04-30 15:55:34.000 |
Context
2008-04-30
| ||
16:38 | Add comment to speculate when setting journal_mode=OFF on VACUUM does not help performance. No changes to code. (CVS 5071) (check-in: 9c8b4babb2 user: drh tags: trunk) | |
15:55 | Improved option handling in speedtest8.c. Added -quiet and -priority options. Added reporting of total user and system time. (CVS 5070) (check-in: aa59974ec1 user: shane tags: trunk) | |
08:56 | Fix test for buffer overrun in unixGettempname(). Fix for #3091. (CVS 5069) (check-in: fc0ca647bd user: danielk1977 tags: trunk) | |
Changes
Changes to tool/speedtest8.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 | ** ./a.out test.db test.sql */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <unistd.h> | > | > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** ./a.out test.db test.sql */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <unistd.h> #include <sys/times.h> #include <time.h> #include <sched.h> #include "sqlite3.h" /* ** The following routine only works on pentium-class processors. ** It uses the RDTSC opcode to read the cycle count value out of the ** processor and returns that value. This can be used for high-res ** profiling. */ |
︙ | ︙ | |||
48 49 50 51 52 53 54 | static unsigned long long int prepTime = 0; static unsigned long long int runTime = 0; static unsigned long long int finalizeTime = 0; /* ** Prepare and run a single statement of SQL. */ | | | | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | static unsigned long long int prepTime = 0; static unsigned long long int runTime = 0; static unsigned long long int finalizeTime = 0; /* ** Prepare and run a single statement of SQL. */ static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){ sqlite3_stmt *pStmt; const char *stmtTail; unsigned long long int iStart, iElapse; int rc; if (!bQuiet) printf("****************************************************************\n"); if (!bQuiet) printf("SQL statement: [%s]\n", zSql); iStart = hwtime(); rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail); iElapse = hwtime() - iStart; prepTime += iElapse; if (!bQuiet) printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse); if( rc==SQLITE_OK ){ int nRow = 0; iStart = hwtime(); while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; } iElapse = hwtime() - iStart; runTime += iElapse; if (!bQuiet) printf("sqlite3_step() returns %d after %d rows in %llu cycles\n", rc, nRow, iElapse); iStart = hwtime(); rc = sqlite3_finalize(pStmt); iElapse = hwtime() - iStart; finalizeTime += iElapse; if (!bQuiet) printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse); } } /*************************************************************************** ** The "overwrite" VFS is an overlay over the default VFS. It modifies ** the xTruncate operation on journal files so that xTruncate merely ** writes zeros into the first 50 bytes of the file rather than truely |
︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 | int i, j; FILE *in; unsigned long long int iStart, iElapse; unsigned long long int iSetup = 0; int nStmt = 0; int nByte = 0; const char *zArgv0 = argv[0]; #ifdef HAVE_OSINST extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *); extern void sqlite3_instvfs_destroy(sqlite3_vfs *); sqlite3_vfs *pVfs = 0; #endif | > > > > > | | | | > | | | | | | > | > > > > > | > > > > > > > > > > > > > | > > | | > > > > | | > > > > > > > | | > | | > | > | | | | | | | > > > > > | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | int i, j; FILE *in; unsigned long long int iStart, iElapse; unsigned long long int iSetup = 0; int nStmt = 0; int nByte = 0; const char *zArgv0 = argv[0]; int bQuiet = 0; struct tms tmsStart, tmsEnd; clock_t clkStart, clkEnd; #ifdef HAVE_OSINST extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *); extern void sqlite3_instvfs_destroy(sqlite3_vfs *); sqlite3_vfs *pVfs = 0; #endif while (argc>3) { if( argc>3 && strcmp(argv[1], "-overwrite")==0 ){ registerOverwriteVfs(); argv++; argc--; continue; } #ifdef HAVE_OSINST if( argc>4 && (strcmp(argv[1], "-log")==0) ){ pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]); sqlite3_vfs_register(pVfs, 1); argv += 2; argc -= 2; continue; } #endif /* ** Increasing the priority slightly above normal can help with repeatability ** of testing. Note that with Cygwin, -5 equates to "High", +5 equates to "Low", ** and anything in between equates to "Normal". */ if( argc>4 && (strcmp(argv[1], "-priority")==0) ){ struct sched_param myParam; sched_getparam(0, &myParam); printf ("Current process priority is %d.\n", (int)myParam.sched_priority); myParam.sched_priority = atoi(argv[2]); printf ("Setting process priority to %d.\n", (int)myParam.sched_priority); if (sched_setparam (0, &myParam) != 0){ printf ("error setting priority\n"); exit(2); } argv += 2; argc -= 2; continue; } if( argc>3 && strcmp(argv[1], "-quiet")==0 ){ bQuiet = -1; argv++; argc--; continue; } break; } if( argc!=3 ){ fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n" "Runs SQL-SCRIPT against a UTF8 database\n" "\toptions:\n" "\t-overwrite\n" #ifdef HAVE_OSINST "\t-log <log>\n" #endif "\t-priority <value> : set priority of task\n" "\t-quiet : only display summary results\n", zArgv0); exit(1); } in = fopen(argv[2], "r"); fseek(in, 0L, SEEK_END); nSql = ftell(in); zSql = malloc( nSql+1 ); fseek(in, 0L, SEEK_SET); nSql = fread(zSql, 1, nSql, in); zSql[nSql] = 0; printf("SQLite version: %d\n", sqlite3_libversion_number()); unlink(argv[1]); clkStart = times(&tmsStart); iStart = hwtime(); rc = sqlite3_open(argv[1], &db); iElapse = hwtime() - iStart; iSetup = iElapse; if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse); for(i=j=0; j<nSql; j++){ if( zSql[j]==';' ){ int isComplete; char c = zSql[j+1]; zSql[j+1] = 0; isComplete = sqlite3_complete(&zSql[i]); zSql[j+1] = c; if( isComplete ){ zSql[j] = 0; while( i<j && isspace(zSql[i]) ){ i++; } if( i<j ){ int n = j - i; if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1); nStmt++; nByte += n; prepareAndRun(db, &zSql[i], bQuiet); } zSql[j] = ';'; i = j+1; } } } iStart = hwtime(); sqlite3_close(db); iElapse = hwtime() - iStart; clkEnd = times(&tmsEnd); iSetup += iElapse; if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse); printf("\n"); printf("Statements run: %15d stmts\n", nStmt); printf("Bytes of SQL text: %15d bytes\n", nByte); printf("Total prepare time: %15llu cycles\n", prepTime); printf("Total run time: %15llu cycles\n", runTime); printf("Total finalize time: %15llu cycles\n", finalizeTime); printf("Open/Close time: %15llu cycles\n", iSetup); printf("Total time: %15llu cycles\n", prepTime + runTime + finalizeTime + iSetup); printf("\n"); printf("Total user CPU time: %15.3g secs\n", (tmsEnd.tms_utime - tmsStart.tms_utime)/(double)CLOCKS_PER_SEC ); printf("Total system CPU time: %15.3g secs\n", (tmsEnd.tms_stime - tmsStart.tms_stime)/(double)CLOCKS_PER_SEC ); printf("Total real time: %15.3g secs\n", (clkEnd -clkStart)/(double)CLOCKS_PER_SEC ); #ifdef HAVE_OSINST if( pVfs ){ sqlite3_instvfs_destroy(pVfs); printf("vfs log written to %s\n", argv[0]); } #endif return 0; } |