]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the --timer option to the wordcount test program.
authordrh <drh@noemail.net>
Thu, 21 Nov 2013 19:27:45 +0000 (19:27 +0000)
committerdrh <drh@noemail.net>
Thu, 21 Nov 2013 19:27:45 +0000 (19:27 +0000)
FossilOrigin-Name: a89fdf87553f01c150729c570796b5078a9b069d

manifest
manifest.uuid
test/wordcount.c

index 71b6ca6a996a9ae51451ac094621e6f2a8e79cf2..45a9f70ccbc1cd2e86a452223aa4403bf6daa07f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sa\stest\sfrom\ssqlite3VdbeMemFromBtree()\swhich\swas\sunnecessary,\sand\nafter\sthe\srecent\sOP_Column\srefactoring,\sunreachable.
-D 2013-11-21T19:05:04.606
+C Add\sthe\s--timer\soption\sto\sthe\swordcount\stest\sprogram.
+D 2013-11-21T19:27:45.727
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 8a07bebafbfda0eb67728f4bd15a36201662d1a1
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -1088,7 +1088,7 @@ F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8
 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
 F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0
 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
-F test/wordcount.c c80f378f26fbf6ada602c4313ae88fc47439263e
+F test/wordcount.c a42341b7a01229782b9bd97ff2eeebae830adbea
 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
 F test/zerodamage.test 209d7ed441f44cc5299e4ebffbef06fd5aabfefd
 F tool/build-all-msvc.bat 1bac6adc3fdb4d9204f21d17b14be25778370e48 x
@@ -1140,7 +1140,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P d4ccf0f5c656c8f0e1c32d5f7971b131f42c3cbd
-R 66dccb4d546e53b7ddedb9ff6684fbe4
+P 23667f3ba09b7e839d76c42669dc9247a91262c8
+R 6f7d4c37e1e4a4d7b173a8698f60d4e6
 U drh
-Z 06ed94041404ba9e41a5bfcb0e125483
+Z be6cc4796ccce786831080c9b4f10bd9
index d71d94e1bf50e5072bec733209c4323daf37ef31..a07e42dce4d875d7418459b95444ad4511a46520 100644 (file)
@@ -1 +1 @@
-23667f3ba09b7e839d76c42669dc9247a91262c8
\ No newline at end of file
+a89fdf87553f01c150729c570796b5078a9b069d
\ No newline at end of file
index 59d8540a054f445a17cd61f223a2478ada992273..c4d641b1e919f9627f2313b15c55607d68bb4f40 100644 (file)
@@ -29,6 +29,7 @@
 **     --commit NNN         Commit after every NNN operations
 **     --nosync             Use PRAGMA synchronous=OFF
 **     --journal MMMM       Use PRAGMA journal_mode=MMMM
+**     --timer              Time the operation of this program
 **
 ** Modes:
 **
 #include <stdarg.h>
 #include "sqlite3.h"
 
+/* Return the current wall-clock time */
+static sqlite3_int64 realTime(void){
+  static sqlite3_vfs *clockVfs = 0;
+  sqlite3_int64 t;
+  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+  if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
+    clockVfs->xCurrentTimeInt64(clockVfs, &t);
+  }else{
+    double r;
+    clockVfs->xCurrentTime(clockVfs, &r);
+    t = (sqlite3_int64)(r*86400000.0);
+  }
+  return t;
+}
+
 /* Print an error message and exit */
 static void fatal_error(const char *zMsg, ...){
   va_list ap;
@@ -186,6 +202,7 @@ int main(int argc, char **argv){
   int doTrace = 0;              /* True for --trace */
   int showStats = 0;            /* True for --stats */
   int showSummary = 0;          /* True for --summary */
+  int showTimer = 0;            /* True for --timer */
   int cacheSize = 0;            /* Desired cache size.  0 means default */
   int pageSize = 0;             /* Desired page size.  0 means default */
   int commitInterval = 0;       /* How often to commit.  0 means never */
@@ -203,6 +220,7 @@ int main(int argc, char **argv){
   int rc;                       /* Return code from an SQLite interface */
   int iCur, iHiwtr;             /* Statistics values, current and "highwater" */
   sqlite3_int64 sumCnt = 0;     /* Sum in QUERY mode */
+  sqlite3_int64 startTime;
   char zInput[2000];            /* A single line of input */
 
   /* Process command-line arguments */
@@ -234,6 +252,8 @@ int main(int argc, char **argv){
         showStats = 1;
       }else if( strcmp(z,"summary")==0 ){
         showSummary = 1;
+      }else if( strcmp(z,"timer")==0 ){
+        showTimer = i;
       }else if( strcmp(z,"cachesize")==0 && i<argc-1 ){
         i++;
         cacheSize = atoi(argv[i]);
@@ -259,6 +279,7 @@ int main(int argc, char **argv){
   if( zDbName==0 ){
     fatal_error("Usage: %s [--options] DATABASE [INPUTFILE]\n", argv[0]);
   }
+  startTime = realTime();
 
   /* Open the database and the input file */
   if( sqlite3_open(zDbName, &db) ){
@@ -449,6 +470,14 @@ int main(int argc, char **argv){
     sqlite3_finalize(pSelect);
   }
 
+
+  if( showTimer ){
+    sqlite3_int64 elapseTime = realTime() - startTime;
+    printf("/* %3d.%03d", (int)(elapseTime/1000), (int)(elapseTime%1000));
+    for(i=0; i<argc; i++) if( i!=showTimer ) printf(" %s", argv[i]);
+    printf(" */\n");
+  }
+
   if( showSummary ){
     sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
                             0, checksumStep, checksumFinalize);