-C Avoid\san\sout-of-bounds\sread\sin\ssqlite3_prepare()\sand\sfix\sa\scase\swhere\sthe\soutput\svariable\s*pzTail\swas\sbeing\sset\sincorrectly.\sFix\sfor\s#3027.\s(CVS\s4957)
-D 2008-04-03T14:36:26
+C Add\sthe\sspeedtest8.c\sand\sspeedtest16.c\sfiles\sto\sthe\stools\ssubdirectory.\s(CVS\s4958)
+D 2008-04-03T16:01:28
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in b861627d91df5ee422c54237aa38296954dc0151
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
+F tool/speedtest16.c 130615cf89ad76fa87fcf16a2205ce53510fc330
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
+F tool/speedtest8.c bbe608e9ac57f64fd324ecb23de54ab17cd86dba
F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20
F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
F www/arch.gif f845a64772062e82d17980a349f95f1f0b4c8054
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P fd97f8762cb1e4653c932402940f74d7c0ebf71f
-R 4cbad59c692acf4f8287734f3525dd14
-U danielk1977
-Z e74a22ea6ae0b08ba9441bfc8876ae6c
+P c287a7b29410be12cf88f886e8e2525a42aa9c03
+R 9d9b96d2bd32dc055499d78c524c19f5
+U drh
+Z 1c72cd047a86a988a7649faaab8ab44b
-c287a7b29410be12cf88f886e8e2525a42aa9c03
\ No newline at end of file
+b8d211a76fa56d812fc1758b58d65eef832494cb
\ No newline at end of file
--- /dev/null
+/*
+** Performance test for SQLite.
+**
+** This program reads ASCII text from a file named on the command-line.
+** It converts each SQL statement into UTF16 and submits it to SQLite
+** for evaluation. A new UTF16 database is created at the beginning of
+** the program. All statements are timed using the high-resolution timer
+** built into Intel-class processors.
+**
+** To compile this program, first compile the SQLite library separately
+** will full optimizations. For example:
+**
+** gcc -c -O6 -DSQLITE_THREADSAFE=0 sqlite3.c
+**
+** Then link against this program. But to do optimize this program
+** because that defeats the hi-res timer.
+**
+** gcc speedtest16.c sqlite3.o -ldl
+**
+** Then run this program with a single argument which is the name of
+** a file containing SQL script that you want to test:
+**
+** ./a.out test.sql
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.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.
+*/
+__inline__ unsigned long long int hwtime(void){
+ unsigned long long int x;
+ __asm__("rdtsc\n\t"
+ "mov %%edx, %%ecx\n\t"
+ :"=A" (x));
+ return x;
+}
+
+/*
+** Convert a zero-terminated ASCII string into a zero-terminated
+** UTF-16le string. Memory to hold the returned string comes
+** from malloc() and should be freed by the caller.
+*/
+static void *asciiToUtf16le(const char *z){
+ int n = strlen(z);
+ char *z16;
+ int i, j;
+
+ z16 = malloc( n*2 + 2 );
+ for(i=j=0; i<=n; i++){
+ z16[j++] = z[i];
+ z16[j++] = 0;
+ }
+ return (void*)z16;
+}
+
+/*
+** Timers
+*/
+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){
+ void *utf16;
+ sqlite3_stmt *pStmt;
+ const void *stmtTail;
+ unsigned long long int iStart, iElapse;
+ int rc;
+
+ printf("****************************************************************\n");
+ printf("SQL statement: [%s]\n", zSql);
+ utf16 = asciiToUtf16le(zSql);
+ iStart = hwtime();
+ rc = sqlite3_prepare16_v2(db, utf16, -1, &pStmt, &stmtTail);
+ iElapse = hwtime() - iStart;
+ prepTime += iElapse;
+ printf("sqlite3_prepare16_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;
+ 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;
+ printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
+ }
+ free(utf16);
+}
+
+int main(int argc, char **argv){
+ void *utf16;
+ sqlite3 *db;
+ int rc;
+ int nSql;
+ char *zSql;
+ int i, j;
+ FILE *in;
+ unsigned long long int iStart, iElapse;
+ unsigned long long int iSetup = 0;
+
+ if( argc!=2 ){
+ fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
+ "Runs SQL-SCRIPT as UTF16 against a UTF16 database\n",
+ argv[0]);
+ exit(1);
+ }
+ in = fopen(argv[1], "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("test.db");
+ unlink("test.db-journal");
+ utf16 = asciiToUtf16le("test.db");
+ iStart = hwtime();
+ rc = sqlite3_open16(utf16, &db);
+ iElapse = hwtime() - iStart;
+ iSetup = iElapse;
+ printf("sqlite3_open16() returns %d in %llu cycles\n", rc, iElapse);
+ free(utf16);
+ 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 ){
+ prepareAndRun(db, &zSql[i]);
+ }
+ zSql[j] = ';';
+ i = j+1;
+ }
+ }
+ }
+ iStart = hwtime();
+ sqlite3_close(db);
+ iElapse = hwtime() - iStart;
+ iSetup += iElapse;
+ printf("sqlite3_close() returns in %llu cycles\n", iElapse);
+ printf("\n");
+ 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);
+ return 0;
+}
--- /dev/null
+/*
+** Performance test for SQLite.
+**
+** This program reads ASCII text from a file named on the command-line
+** and submits that text to SQLite for evaluation. A new database
+** is created at the beginning of the program. All statements are
+** timed using the high-resolution timer built into Intel-class processors.
+**
+** To compile this program, first compile the SQLite library separately
+** will full optimizations. For example:
+**
+** gcc -c -O6 -DSQLITE_THREADSAFE=0 sqlite3.c
+**
+** Then link against this program. But to do optimize this program
+** because that defeats the hi-res timer.
+**
+** gcc speedtest8.c sqlite3.o -ldl
+**
+** Then run this program with a single argument which is the name of
+** a file containing SQL script that you want to test:
+**
+** ./a.out test.sql
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.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.
+*/
+__inline__ unsigned long long int hwtime(void){
+ unsigned long long int x;
+ __asm__("rdtsc\n\t"
+ "mov %%edx, %%ecx\n\t"
+ :"=A" (x));
+ return x;
+}
+
+/*
+** Timers
+*/
+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){
+ sqlite3_stmt *pStmt;
+ const char *stmtTail;
+ unsigned long long int iStart, iElapse;
+ int rc;
+
+ printf("****************************************************************\n");
+ printf("SQL statement: [%s]\n", zSql);
+ iStart = hwtime();
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);
+ iElapse = hwtime() - iStart;
+ prepTime += iElapse;
+ 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;
+ 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;
+ printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
+ }
+}
+
+int main(int argc, char **argv){
+ sqlite3 *db;
+ int rc;
+ int nSql;
+ char *zSql;
+ int i, j;
+ FILE *in;
+ unsigned long long int iStart, iElapse;
+ unsigned long long int iSetup = 0;
+
+ if( argc!=2 ){
+ fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
+ "Runs SQL-SCRIPT against a UTF8 database\n",
+ argv[0]);
+ exit(1);
+ }
+ in = fopen(argv[1], "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("test.db");
+ unlink("test.db-journal");
+ iStart = hwtime();
+ rc = sqlite3_open("test.db", &db);
+ iElapse = hwtime() - iStart;
+ iSetup = iElapse;
+ 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 ){
+ prepareAndRun(db, &zSql[i]);
+ }
+ zSql[j] = ';';
+ i = j+1;
+ }
+ }
+ }
+ iStart = hwtime();
+ sqlite3_close(db);
+ iElapse = hwtime() - iStart;
+ iSetup += iElapse;
+ printf("sqlite3_close() returns in %llu cycles\n", iElapse);
+ printf("\n");
+ 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);
+ return 0;
+}