]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Have the shell ".timer on" command cause the shell to report wall-clock time for... shell-wall-clock
authordan <dan@noemail.net>
Wed, 30 Oct 2013 12:30:05 +0000 (12:30 +0000)
committerdan <dan@noemail.net>
Wed, 30 Oct 2013 12:30:05 +0000 (12:30 +0000)
FossilOrigin-Name: 5530cdc4857f7410ce6ddf53ae94c75426e19eee

manifest
manifest.uuid
src/shell.c

index f66ec4132d3b8623cc117161270dd1bbe0178b6d..69197ca84a27b4fbdc79bffad4b8541eb13b62e8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Formatting\simprovements\sto\sthe\sWHERE-clause\sconstraint\sdisplay\sin\sthe\nwheretrace\sdebugging\slogic.
-D 2013-10-28T22:33:36.558
+C Have\sthe\sshell\s".timer\son"\scommand\scause\sthe\sshell\sto\sreport\swall-clock\stime\sfor\seach\squery\s(as\swell\sas\suser\sand\ssystem\sCPU\stime).
+D 2013-10-30T12:30:05.137
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -219,7 +219,7 @@ F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
 F src/resolve.c 572585a96bf282bb9c3d9e08785ec3cae21dc488
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4
-F src/shell.c d5eebdc6034014103de2b9d58e1d3f6f7de0fb50
+F src/shell.c 43647b08b6114823fe2e39b1e14934fa39dd22f3
 F src/sqlite.h.in 547a44dd4ff4d975e92a645ea2d609e543a83d0f
 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
@@ -1126,7 +1126,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 05a35b09b140fed0898afd36bc641e275545a35f
-R ff7bb3f8071649882bf49e664fcf0a45
-U drh
-Z 9d63edd4f24f764673ec22cc76454487
+P 3a9e3ed94bf617f00c48009b1a6d348a8f23a3cf
+R 057f871d4d3691cf245ceb2d9e03344d
+T *branch * shell-wall-clock
+T *sym-shell-wall-clock *
+T -sym-trunk *
+U dan
+Z 19a81cac8d9e008c0c4c0cd627a27a59
index 9f87ae481e804e56f04175f403abf00bae8b8cb2..122b067528c85d9d4b4e373ab091b66b05085aae 100644 (file)
@@ -1 +1 @@
-3a9e3ed94bf617f00c48009b1a6d348a8f23a3cf
\ No newline at end of file
+5530cdc4857f7410ce6ddf53ae94c75426e19eee
\ No newline at end of file
index 26c38c59ea4532977c6b8ad80c527d88ec1c8981..3bcf8c93ffe10d80b649b8ed3b238b3ef82d295b 100644 (file)
@@ -100,14 +100,37 @@ static int enableTimer = 0;
 #include <sys/resource.h>
 
 /* Saved resource information for the beginning of an operation */
-static struct rusage sBegin;
+static struct TimerData {
+  struct rusage sRusage;
+  sqlite3_int64 iTime;
+} sBegin;
+
+/*
+** Return the current-time according to the xCurrentTimeInt64() method 
+** of the default VFS (in ms). Use the result of xCurrentTime() to 
+** calculate an equivalent value if the VFS is too old for 
+** xCurrentTimeInt64().
+*/
+static sqlite3_int64 vfsCurrentTime64(void){
+  sqlite3_int64 iRet;
+  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
+  if( pVfs->iVersion>=2 ){
+    pVfs->xCurrentTimeInt64(pVfs, &iRet);
+  }else{
+    double t;
+    pVfs->xCurrentTime(pVfs, &t);
+    iRet = (sqlite3_int64)(t * 86400000.0);
+  }
+  return iRet;
+}
 
 /*
 ** Begin timing an operation
 */
 static void beginTimer(void){
   if( enableTimer ){
-    getrusage(RUSAGE_SELF, &sBegin);
+    sBegin.iTime = vfsCurrentTime64();
+    getrusage(RUSAGE_SELF, &sBegin.sRusage);
   }
 }
 
@@ -124,9 +147,11 @@ static void endTimer(void){
   if( enableTimer ){
     struct rusage sEnd;
     getrusage(RUSAGE_SELF, &sEnd);
-    printf("CPU Time: user %f sys %f\n",
-       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
-       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
+    printf("CPU Time: user %f sys %f wall %f\n",
+       timeDiff(&sBegin.sRusage.ru_utime, &sEnd.ru_utime),
+       timeDiff(&sBegin.sRusage.ru_stime, &sEnd.ru_stime),
+       (double)(vfsCurrentTime64() - sBegin.iTime) / 1000.0
+    );
   }
 }