| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** Performance test for SQLite. | 2 ** Performance test for SQLite. |
| 3 ** | 3 ** |
| 4 ** This program reads ASCII text from a file named on the command-line | 4 ** This program reads ASCII text from a file named on the command-line |
| 5 ** and submits that text to SQLite for evaluation. A new database | 5 ** and submits that text to SQLite for evaluation. A new database |
| 6 ** is created at the beginning of the program. All statements are | 6 ** is created at the beginning of the program. All statements are |
| 7 ** timed using the high-resolution timer built into Intel-class processors. | 7 ** timed using the high-resolution timer built into Intel-class processors. |
| 8 ** | 8 ** |
| 9 ** To compile this program, first compile the SQLite library separately | 9 ** To compile this program, first compile the SQLite library separately |
| 10 ** will full optimizations. For example: | 10 ** will full optimizations. For example: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ** ./a.out test.db test.sql | 22 ** ./a.out test.db test.sql |
| 23 */ | 23 */ |
| 24 #include <stdio.h> | 24 #include <stdio.h> |
| 25 #include <string.h> | 25 #include <string.h> |
| 26 #include <stdlib.h> | 26 #include <stdlib.h> |
| 27 #include <ctype.h> | 27 #include <ctype.h> |
| 28 #include <unistd.h> | 28 #include <unistd.h> |
| 29 #include <stdarg.h> | 29 #include <stdarg.h> |
| 30 #include "sqlite3.h" | 30 #include "sqlite3.h" |
| 31 | 31 |
| 32 #define ISSPACE(X) isspace((unsigned char)(X)) |
| 33 |
| 32 #include "test_osinst.c" | 34 #include "test_osinst.c" |
| 33 | 35 |
| 34 /* | 36 /* |
| 35 ** Prepare and run a single statement of SQL. | 37 ** Prepare and run a single statement of SQL. |
| 36 */ | 38 */ |
| 37 static void prepareAndRun(sqlite3_vfs *pInstVfs, sqlite3 *db, const char *zSql){ | 39 static void prepareAndRun(sqlite3_vfs *pInstVfs, sqlite3 *db, const char *zSql){ |
| 38 sqlite3_stmt *pStmt; | 40 sqlite3_stmt *pStmt; |
| 39 const char *stmtTail; | 41 const char *stmtTail; |
| 40 int rc; | 42 int rc; |
| 41 char zMessage[1024]; | 43 char zMessage[1024]; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 192 |
| 191 for(i=j=0; j<nSql; j++){ | 193 for(i=j=0; j<nSql; j++){ |
| 192 if( zSql[j]==';' ){ | 194 if( zSql[j]==';' ){ |
| 193 int isComplete; | 195 int isComplete; |
| 194 char c = zSql[j+1]; | 196 char c = zSql[j+1]; |
| 195 zSql[j+1] = 0; | 197 zSql[j+1] = 0; |
| 196 isComplete = sqlite3_complete(&zSql[i]); | 198 isComplete = sqlite3_complete(&zSql[i]); |
| 197 zSql[j+1] = c; | 199 zSql[j+1] = c; |
| 198 if( isComplete ){ | 200 if( isComplete ){ |
| 199 zSql[j] = 0; | 201 zSql[j] = 0; |
| 200 while( i<j && isspace(zSql[i]) ){ i++; } | 202 while( i<j && ISSPACE(zSql[i]) ){ i++; } |
| 201 if( i<j ){ | 203 if( i<j ){ |
| 202 prepareAndRun(pInstVfs, db, &zSql[i]); | 204 prepareAndRun(pInstVfs, db, &zSql[i]); |
| 203 } | 205 } |
| 204 zSql[j] = ';'; | 206 zSql[j] = ';'; |
| 205 i = j+1; | 207 i = j+1; |
| 206 } | 208 } |
| 207 } | 209 } |
| 208 } | 210 } |
| 209 | 211 |
| 210 sqlite3_instvfs_destroy(pInstVfs); | 212 sqlite3_instvfs_destroy(pInstVfs); |
| 211 return 0; | 213 return 0; |
| 212 | 214 |
| 213 usage: | 215 usage: |
| 214 fprintf(stderr, zUsageMsg, argv[0]); | 216 fprintf(stderr, zUsageMsg, argv[0]); |
| 215 return -3; | 217 return -3; |
| 216 } | 218 } |
| OLD | NEW |