]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved option handling in speedtest8.c. Added -quiet and -priority options. Added...
authorshane <shane@noemail.net>
Wed, 30 Apr 2008 15:55:33 +0000 (15:55 +0000)
committershane <shane@noemail.net>
Wed, 30 Apr 2008 15:55:33 +0000 (15:55 +0000)
FossilOrigin-Name: aa59974ec15508d69c5b65ab89ec7bc32690018c

manifest
manifest.uuid
tool/speedtest8.c

index 7f80690b7285a7dadd5ed8a5a1a6ca5140b4d66c..f26fd0202a9e6321c17cacd0e6010947c97ad200 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\stest\sfor\sbuffer\soverrun\sin\sunixGettempname().\sFix\sfor\s#3091.\s(CVS\s5069)
-D 2008-04-30T08:56:10
+C Improved\soption\shandling\sin\sspeedtest8.c.\s\sAdded\s-quiet\sand\s-priority\soptions.\s\sAdded\sreporting\sof\stotal\suser\sand\ssystem\stime.\s(CVS\s5070)
+D 2008-04-30T15:55:34
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -573,7 +573,7 @@ F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39
 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
 F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
-F tool/speedtest8.c fd53bf13c7bbea4671faa2222cbb3286c14200f8
+F tool/speedtest8.c a7cd2b2dbb8f97b0c51c0e01f49116a9162071be
 F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854
 F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20
 F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
@@ -633,7 +633,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P f854ae576ee0b223b86a1169178fc4399e8d08ce
-R dc0d12af7248df7518eb5354b7eeb383
-U danielk1977
-Z 6533bd0cfc41b7cb37a38e5960f73499
+P fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34
+R 8bd12bf8a3eaadb4e117c1f015393938
+U shane
+Z 09702a98c8183287a6fdc49d86797b33
index fa37fc19d8af31b809d76ed51395e2b1de4cf53a..49e5a1914d680a6657bd56fbeb3ac1affa78b910 100644 (file)
@@ -1 +1 @@
-fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34
\ No newline at end of file
+aa59974ec15508d69c5b65ab89ec7bc32690018c
\ No newline at end of file
index 43d77f2415b5bc9e898fdad73ba628e73cb3e252..207c080ebc64859bf19748afe06e818f6dcb6ce0 100644 (file)
-/*
-** 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.db  test.sql
-*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.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 int lo, hi;
-   /* We cannot use "=A", since this would use %rax on x86_64 */
-   __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
-   return (unsigned long long int)hi << 32 | lo;
-}
-
-/*
-** 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);
-  }
-}
-
-/***************************************************************************
-** 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
-** truncating the file.
-**
-** The following variables are initialized to be the virtual function
-** tables for the overwrite VFS.
-*/
-static sqlite3_vfs overwrite_vfs;
-static sqlite3_io_methods overwrite_methods;
-
-/*
-** The truncate method for journal files in the overwrite VFS.
-*/
-static int overwriteTruncate(sqlite3_file *pFile, sqlite_int64 size){
-  int rc;
-  static const char buf[50];
-  if( size ){
-    return SQLITE_IOERR;
-  }
-  rc = pFile->pMethods->xWrite(pFile, buf, sizeof(buf), 0);
-  if( rc==SQLITE_OK ){
-    rc = pFile->pMethods->xSync(pFile, SQLITE_SYNC_NORMAL);
-  }
-  return rc;
-}
-
-/*
-** The delete method for journal files in the overwrite VFS.
-*/
-static int overwriteDelete(sqlite3_file *pFile){
-  return overwriteTruncate(pFile, 0);
-}
-
-/*
-** The open method for overwrite VFS.  If the file being opened is
-** a journal file then substitute the alternative xTruncate method.
-*/
-static int overwriteOpen(
-  sqlite3_vfs *pVfs,
-  const char *zName,
-  sqlite3_file *pFile,
-  int flags,
-  int *pOutFlags
-){
-  int rc;
-  sqlite3_vfs *pRealVfs;
-  int isJournal;
-
-  isJournal = (flags & (SQLITE_OPEN_MAIN_JOURNAL|SQLITE_OPEN_TEMP_JOURNAL))!=0;
-  pRealVfs = (sqlite3_vfs*)pVfs->pAppData;
-  rc = pRealVfs->xOpen(pRealVfs, zName, pFile, flags, pOutFlags);
-  if( rc==SQLITE_OK && isJournal ){
-    if( overwrite_methods.xTruncate==0 ){
-      sqlite3_io_methods temp;
-      memcpy(&temp, pFile->pMethods, sizeof(temp));
-      temp.xTruncate = overwriteTruncate;
-      memcpy(&overwrite_methods, &temp, sizeof(temp));
-    }
-    pFile->pMethods = &overwrite_methods;
-  }
-  return rc;
-}
-
-/*
-** Overlay the overwrite VFS over top of the current default VFS
-** and make the overlay VFS the new default.
-**
-** This routine can only be evaluated once.  On second and subsequent
-** executions it becomes a no-op.
-*/
-static void registerOverwriteVfs(void){
-  sqlite3_vfs *pBase;
-  if( overwrite_vfs.iVersion ) return;
-  pBase = sqlite3_vfs_find(0);
-  memcpy(&overwrite_vfs, pBase, sizeof(overwrite_vfs));
-  overwrite_vfs.pAppData = pBase;
-  overwrite_vfs.xOpen = overwriteOpen;
-  overwrite_vfs.zName = "overwriteVfs";
-  sqlite3_vfs_register(&overwrite_vfs, 1);
-}
-
-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;
-  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
-
-  if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){
-    registerOverwriteVfs();
-    argv++;
-    argc--;
-  }
-
-#ifdef HAVE_OSINST
-  if( argc>=5 && strcmp(argv[1], "-log")==0 ){
-    pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]);
-    sqlite3_vfs_register(pVfs, 1);
-    argv += 2;
-    argc -= 2;
-  }
-#endif
-
-  if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){
-    registerOverwriteVfs();
-    argv++;
-    argc--;
-  }
-
-  if( argc!=3 ){
-    fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n"
-                    "Runs SQL-SCRIPT against a UTF8 database\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]);
-  iStart = hwtime();
-  rc = sqlite3_open(argv[1], &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 ){
-          int n = j - i;
-          if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1);
-          nStmt++;
-          nByte += n;
-          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("Statements run:       %15d\n", nStmt);
-  printf("Bytes of SQL text:    %15d\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);
-
-#ifdef HAVE_OSINST
-  if( pVfs ){
-    sqlite3_instvfs_destroy(pVfs);
-    printf("vfs log written to %s\n", argv[0]);
-  }
-#endif
-
-  return 0;
-}
+/*\r
+** Performance test for SQLite.\r
+**\r
+** This program reads ASCII text from a file named on the command-line\r
+** and submits that text  to SQLite for evaluation.  A new database\r
+** is created at the beginning of the program.  All statements are\r
+** timed using the high-resolution timer built into Intel-class processors.\r
+**\r
+** To compile this program, first compile the SQLite library separately\r
+** will full optimizations.  For example:\r
+**\r
+**     gcc -c -O6 -DSQLITE_THREADSAFE=0 sqlite3.c\r
+**\r
+** Then link against this program.  But to do optimize this program\r
+** because that defeats the hi-res timer.\r
+**\r
+**     gcc speedtest8.c sqlite3.o -ldl\r
+**\r
+** Then run this program with a single argument which is the name of\r
+** a file containing SQL script that you want to test:\r
+**\r
+**     ./a.out test.db  test.sql\r
+*/\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+#include <unistd.h>\r
+#include <sys/times.h>\r
+#include <time.h>\r
+#include <sched.h>\r
+\r
+#include "sqlite3.h"\r
+\r
+/*\r
+** The following routine only works on pentium-class processors.\r
+** It uses the RDTSC opcode to read the cycle count value out of the\r
+** processor and returns that value.  This can be used for high-res\r
+** profiling.\r
+*/\r
+__inline__ unsigned long long int hwtime(void){\r
+   unsigned int lo, hi;\r
+   /* We cannot use "=A", since this would use %rax on x86_64 */\r
+   __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));\r
+   return (unsigned long long int)hi << 32 | lo;\r
+}\r
+\r
+/*\r
+** Timers\r
+*/\r
+static unsigned long long int prepTime = 0;\r
+static unsigned long long int runTime = 0;\r
+static unsigned long long int finalizeTime = 0;\r
+\r
+/*\r
+** Prepare and run a single statement of SQL.\r
+*/\r
+static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){\r
+  sqlite3_stmt *pStmt;\r
+  const char *stmtTail;\r
+  unsigned long long int iStart, iElapse;\r
+  int rc;\r
+  \r
+  if (!bQuiet) printf("****************************************************************\n");\r
+  if (!bQuiet) printf("SQL statement: [%s]\n", zSql);\r
+  iStart = hwtime();\r
+  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);\r
+  iElapse = hwtime() - iStart;\r
+  prepTime += iElapse;\r
+  if (!bQuiet) printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);\r
+  if( rc==SQLITE_OK ){\r
+    int nRow = 0;\r
+    iStart = hwtime();\r
+    while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }\r
+    iElapse = hwtime() - iStart;\r
+    runTime += iElapse;\r
+    if (!bQuiet) printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",\r
+           rc, nRow, iElapse);\r
+    iStart = hwtime();\r
+    rc = sqlite3_finalize(pStmt);\r
+    iElapse = hwtime() - iStart;\r
+    finalizeTime += iElapse;\r
+    if (!bQuiet) printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);\r
+  }\r
+}\r
+\r
+/***************************************************************************\r
+** The "overwrite" VFS is an overlay over the default VFS.  It modifies\r
+** the xTruncate operation on journal files so that xTruncate merely\r
+** writes zeros into the first 50 bytes of the file rather than truely\r
+** truncating the file.\r
+**\r
+** The following variables are initialized to be the virtual function\r
+** tables for the overwrite VFS.\r
+*/\r
+static sqlite3_vfs overwrite_vfs;\r
+static sqlite3_io_methods overwrite_methods;\r
+\r
+/*\r
+** The truncate method for journal files in the overwrite VFS.\r
+*/\r
+static int overwriteTruncate(sqlite3_file *pFile, sqlite_int64 size){\r
+  int rc;\r
+  static const char buf[50];\r
+  if( size ){\r
+    return SQLITE_IOERR;\r
+  }\r
+  rc = pFile->pMethods->xWrite(pFile, buf, sizeof(buf), 0);\r
+  if( rc==SQLITE_OK ){\r
+    rc = pFile->pMethods->xSync(pFile, SQLITE_SYNC_NORMAL);\r
+  }\r
+  return rc;\r
+}\r
+\r
+/*\r
+** The delete method for journal files in the overwrite VFS.\r
+*/\r
+static int overwriteDelete(sqlite3_file *pFile){\r
+  return overwriteTruncate(pFile, 0);\r
+}\r
+\r
+/*\r
+** The open method for overwrite VFS.  If the file being opened is\r
+** a journal file then substitute the alternative xTruncate method.\r
+*/\r
+static int overwriteOpen(\r
+  sqlite3_vfs *pVfs,\r
+  const char *zName,\r
+  sqlite3_file *pFile,\r
+  int flags,\r
+  int *pOutFlags\r
+){\r
+  int rc;\r
+  sqlite3_vfs *pRealVfs;\r
+  int isJournal;\r
+\r
+  isJournal = (flags & (SQLITE_OPEN_MAIN_JOURNAL|SQLITE_OPEN_TEMP_JOURNAL))!=0;\r
+  pRealVfs = (sqlite3_vfs*)pVfs->pAppData;\r
+  rc = pRealVfs->xOpen(pRealVfs, zName, pFile, flags, pOutFlags);\r
+  if( rc==SQLITE_OK && isJournal ){\r
+    if( overwrite_methods.xTruncate==0 ){\r
+      sqlite3_io_methods temp;\r
+      memcpy(&temp, pFile->pMethods, sizeof(temp));\r
+      temp.xTruncate = overwriteTruncate;\r
+      memcpy(&overwrite_methods, &temp, sizeof(temp));\r
+    }\r
+    pFile->pMethods = &overwrite_methods;\r
+  }\r
+  return rc;\r
+}\r
+\r
+/*\r
+** Overlay the overwrite VFS over top of the current default VFS\r
+** and make the overlay VFS the new default.\r
+**\r
+** This routine can only be evaluated once.  On second and subsequent\r
+** executions it becomes a no-op.\r
+*/\r
+static void registerOverwriteVfs(void){\r
+  sqlite3_vfs *pBase;\r
+  if( overwrite_vfs.iVersion ) return;\r
+  pBase = sqlite3_vfs_find(0);\r
+  memcpy(&overwrite_vfs, pBase, sizeof(overwrite_vfs));\r
+  overwrite_vfs.pAppData = pBase;\r
+  overwrite_vfs.xOpen = overwriteOpen;\r
+  overwrite_vfs.zName = "overwriteVfs";\r
+  sqlite3_vfs_register(&overwrite_vfs, 1);\r
+}\r
+\r
+int main(int argc, char **argv){\r
+  sqlite3 *db;\r
+  int rc;\r
+  int nSql;\r
+  char *zSql;\r
+  int i, j;\r
+  FILE *in;\r
+  unsigned long long int iStart, iElapse;\r
+  unsigned long long int iSetup = 0;\r
+  int nStmt = 0;\r
+  int nByte = 0;\r
+  const char *zArgv0 = argv[0];\r
+  int bQuiet = 0;\r
+  struct tms tmsStart, tmsEnd;\r
+  clock_t clkStart, clkEnd;\r
+\r
+#ifdef HAVE_OSINST\r
+  extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *);\r
+  extern void sqlite3_instvfs_destroy(sqlite3_vfs *);\r
+  sqlite3_vfs *pVfs = 0;\r
+#endif\r
+\r
+  while (argc>3)\r
+  {\r
+    if( argc>3 && strcmp(argv[1], "-overwrite")==0 ){\r
+     registerOverwriteVfs();\r
+     argv++;\r
+     argc--;\r
+     continue;\r
+    }\r
+\r
+#ifdef HAVE_OSINST\r
+    if( argc>4 && (strcmp(argv[1], "-log")==0) ){\r
+     pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]);\r
+     sqlite3_vfs_register(pVfs, 1);\r
+     argv += 2;\r
+     argc -= 2;\r
+     continue;\r
+    }\r
+#endif\r
+\r
+    /*\r
+    ** Increasing the priority slightly above normal can help with repeatability\r
+    ** of testing.  Note that with Cygwin, -5 equates to "High", +5 equates to "Low",\r
+    ** and anything in between equates to "Normal".\r
+    */\r
+    if( argc>4 && (strcmp(argv[1], "-priority")==0) ){\r
+      struct sched_param myParam;\r
+      sched_getparam(0, &myParam);\r
+      printf ("Current process priority is %d.\n", (int)myParam.sched_priority); \r
+      myParam.sched_priority = atoi(argv[2]);\r
+      printf ("Setting process priority to %d.\n", (int)myParam.sched_priority); \r
+      if (sched_setparam (0, &myParam) != 0){\r
+        printf ("error setting priority\n"); \r
+        exit(2); \r
+      }\r
+      argv += 2;\r
+      argc -= 2;\r
+      continue;\r
+    }\r
+\r
+    if( argc>3 && strcmp(argv[1], "-quiet")==0 ){\r
+     bQuiet = -1;\r
+     argv++;\r
+     argc--;\r
+     continue;\r
+    }\r
+\r
+    break;\r
+  }\r
+\r
+  if( argc!=3 ){\r
+   fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n"\r
+              "Runs SQL-SCRIPT against a UTF8 database\n"\r
+              "\toptions:\n"\r
+              "\t-overwrite\n"\r
+#ifdef HAVE_OSINST\r
+              "\t-log <log>\n"\r
+#endif\r
+              "\t-priority <value> : set priority of task\n"\r
+              "\t-quiet : only display summary results\n",\r
+              zArgv0);\r
+   exit(1);\r
+  }\r
+\r
+  in = fopen(argv[2], "r");\r
+  fseek(in, 0L, SEEK_END);\r
+  nSql = ftell(in);\r
+  zSql = malloc( nSql+1 );\r
+  fseek(in, 0L, SEEK_SET);\r
+  nSql = fread(zSql, 1, nSql, in);\r
+  zSql[nSql] = 0;\r
+\r
+  printf("SQLite version: %d\n", sqlite3_libversion_number());\r
+  unlink(argv[1]);\r
+  clkStart = times(&tmsStart);\r
+  iStart = hwtime();\r
+  rc = sqlite3_open(argv[1], &db);\r
+  iElapse = hwtime() - iStart;\r
+  iSetup = iElapse;\r
+  if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);\r
+  for(i=j=0; j<nSql; j++){\r
+    if( zSql[j]==';' ){\r
+      int isComplete;\r
+      char c = zSql[j+1];\r
+      zSql[j+1] = 0;\r
+      isComplete = sqlite3_complete(&zSql[i]);\r
+      zSql[j+1] = c;\r
+      if( isComplete ){\r
+        zSql[j] = 0;\r
+        while( i<j && isspace(zSql[i]) ){ i++; }\r
+        if( i<j ){\r
+          int n = j - i;\r
+          if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1);\r
+          nStmt++;\r
+          nByte += n;\r
+          prepareAndRun(db, &zSql[i], bQuiet);\r
+        }\r
+        zSql[j] = ';';\r
+        i = j+1;\r
+      }\r
+    }\r
+  }\r
+  iStart = hwtime();\r
+  sqlite3_close(db);\r
+  iElapse = hwtime() - iStart;\r
+  clkEnd = times(&tmsEnd);\r
+  iSetup += iElapse;\r
+  if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse);\r
+\r
+  printf("\n");\r
+  printf("Statements run:        %15d stmts\n", nStmt);\r
+  printf("Bytes of SQL text:     %15d bytes\n", nByte);\r
+  printf("Total prepare time:    %15llu cycles\n", prepTime);\r
+  printf("Total run time:        %15llu cycles\n", runTime);\r
+  printf("Total finalize time:   %15llu cycles\n", finalizeTime);\r
+  printf("Open/Close time:       %15llu cycles\n", iSetup);\r
+  printf("Total time:            %15llu cycles\n",\r
+      prepTime + runTime + finalizeTime + iSetup);\r
+\r
+  printf("\n");\r
+  printf("Total user CPU time:   %15.3g secs\n", (tmsEnd.tms_utime - tmsStart.tms_utime)/(double)CLOCKS_PER_SEC );\r
+  printf("Total system CPU time: %15.3g secs\n", (tmsEnd.tms_stime - tmsStart.tms_stime)/(double)CLOCKS_PER_SEC );\r
+  printf("Total real time:       %15.3g secs\n", (clkEnd -clkStart)/(double)CLOCKS_PER_SEC );\r
+\r
+#ifdef HAVE_OSINST\r
+  if( pVfs ){\r
+    sqlite3_instvfs_destroy(pVfs);\r
+    printf("vfs log written to %s\n", argv[0]);\r
+  }\r
+#endif\r
+\r
+  return 0;\r
+}\r