Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Have the shell ".timer on" command cause the shell to report wall-clock time for each query (as well as user and system CPU time). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | shell-wall-clock |
Files: | files | file ages | folders |
SHA1: |
5530cdc4857f7410ce6ddf53ae94c754 |
User & Date: | dan 2013-10-30 12:30:05.137 |
Context
2013-10-30
| ||
12:30 | Have the shell ".timer on" command cause the shell to report wall-clock time for each query (as well as user and system CPU time). (Leaf check-in: 5530cdc485 user: dan tags: shell-wall-clock) | |
2013-10-28
| ||
22:33 | Formatting improvements to the WHERE-clause constraint display in the wheretrace debugging logic. (check-in: 3a9e3ed94b user: drh tags: trunk) | |
Changes
Changes to src/shell.c.
︙ | ︙ | |||
96 97 98 99 100 101 102 | #if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \ && !defined(__minux) #include <sys/time.h> #include <sys/resource.h> /* Saved resource information for the beginning of an operation */ | | > > > > > > > > > > > > > > > > > > > > > > > | | | | > > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | #if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \ && !defined(__minux) #include <sys/time.h> #include <sys/resource.h> /* Saved resource information for the beginning of an operation */ 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 ){ sBegin.iTime = vfsCurrentTime64(); getrusage(RUSAGE_SELF, &sBegin.sRusage); } } /* Return the difference of two time_structs in seconds */ static double timeDiff(struct timeval *pStart, struct timeval *pEnd){ return (pEnd->tv_usec - pStart->tv_usec)*0.000001 + (double)(pEnd->tv_sec - pStart->tv_sec); } /* ** Print the timing results. */ static void endTimer(void){ if( enableTimer ){ struct rusage sEnd; getrusage(RUSAGE_SELF, &sEnd); 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 ); } } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER 1 |
︙ | ︙ |