SQLite

Changes On Branch shell-wall-clock
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch shell-wall-clock Excluding Merge-Ins

This is equivalent to a diff from 3a9e3ed9 to 5530cdc4

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: 5530cdc4 user: dan tags: shell-wall-clock)
2013-10-29
20:40
Automatically generated comments on many VDBE opcodes when in SQLITE_DEBUG mode. Comments derive from the "Synopsis:" field added to each opcode definition in vdbe.c. (check-in: 5f310c6a user: drh tags: trunk)
2013-10-28
22:47
Merge all trunk changes since 3.8.1 into the sessions branch. (check-in: aa72ea8a user: drh tags: sessions)
22:39
Merge recent fixes from trunk. (check-in: 9f8191d1 user: drh tags: omit-rowid)
22:33
Formatting improvements to the WHERE-clause constraint display in the wheretrace debugging logic. (check-in: 3a9e3ed9 user: drh tags: trunk)
20:38
Add regression tests for ticket [c620261b5b5]. (check-in: 05a35b09 user: drh tags: trunk)

Changes to src/shell.c.

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

#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 rusage sBegin;























/*
** Begin timing an operation
*/
static void beginTimer(void){
  if( enableTimer ){

    getrusage(RUSAGE_SELF, &sBegin);
  }
}

/* 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\n",
       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));


  }
}

#define BEGIN_TIMER beginTimer()
#define END_TIMER endTimer()
#define HAS_TIMER 1








|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
|
















|
|
|
>
>







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