$(TOP)/src/func.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
+ $(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
$(TOP)/src/journal.c \
$(TOP)/src/legacy.c \
$(TOP)/src/btree.h \
$(TOP)/src/btreeInt.h \
$(TOP)/src/hash.h \
+ $(TOP)/src/hwtime.h \
$(TOP)/src/sqliteLimit.h \
$(TOP)/src/mutex.h \
opcodes.h \
$(TOP)/src/func.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
+ $(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
$(TOP)/src/journal.c \
$(TOP)/src/legacy.c \
$(TOP)/src/btree.h \
$(TOP)/src/btreeInt.h \
$(TOP)/src/hash.h \
+ $(TOP)/src/hwtime.h \
keywordhash.h \
$(TOP)/src/mutex.h \
opcodes.h \
-C Fix\scosmetic\sissues\sspotted\swhile\sworking\son\sticket\s#3146\s(CVS\s5177)
-D 2008-05-29T05:23:42
+C Consolidated\sinline\sassembly\sversions\sof\s"hwtime()"\sinto\shwtime.h.\s\sProvided\sMSVC\sversion.\s\sModified\scode\sfor\sconsistent\suse\sof\shwtime().\s\sChanged\simplementation\sto\suse\ssqlite_uint64\sand\ssqlite_int64\sinstead\sof\sunsigned\slong\slong\sint\sand\slong\slong\sint\sfor\sMSVC\scompiler\ssupport.\s(CVS\s5178)
+D 2008-05-29T20:22:37
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
-F Makefile.in 62b2a40ff5944dd33c9c3184b21f720ea8e48a44
+F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F README b974cdc3f9f12b87e851b04e75996d720ebf81ac
F VERSION 0993b4f2f08c496fab78af42928b6dc745f8a2e1
F ext/rtree/viewrtree.tcl 09526398dae87a5a87c5aac2b3854dbaf8376869
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh 09fe5815427dc7d0abb188bbcdf0e34896577210
-F main.mk 0fdc9417630e829cae994efee59038810f091e33
+F main.mk 254bdf904af5869178e6b333be5729bf24ff3f77
F mkdll.sh 712e74f3efe08a6ba12b2945d018a29a89d7fe3b
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
F src/func.c 77a910a1ca7613d291fd0b5cba3be14c02f0dce0
F src/hash.c fd8cb06fb54c2fe7d48c9195792059a2e5be8b70
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
+F src/hwtime.h 10fae2093aefa2b00be13bcac40c06e90924bc83
F src/insert.c e3277f313352ac27282b5be39972fda4f315d0c6
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c 8f5a2b25d9673b4004287cf2bf51dbf7d0738406
F src/mutex_w32.c 133698096a2c4e81cd11ea6f4de7891c66f7b9f7
F src/os.c 541ea39fbacc18483b3aa96cd0242bad2dd0f049
F src/os.h 6e7e5d4efdc907b7a1a8cddb0cf984af01843fad
-F src/os_common.h 9da7339466404707af49943fe4c47e608034761b
+F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 1578149e21c4eac42c7f230a6f40500846f8e781
-F src/os_unix.c 06dceb3230249d6e7c6a1d8d602fa6a93f4085b9
+F src/os_unix.c a6b02934fdd4682db47c006cb03baac8694d8b77
F src/os_win.c 812f9ba8cd90c8aa54914a56897fb534494576d8
F src/pager.c d0a77feeaeecaaaec9342a3bb3865ed9a490897a
F src/pager.h 1ccde54041195311c2b09b6936404d2192db44da
F src/test_malloc.c 5c2c698355613d321f216ece25901be1040cc1fb
F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
F src/test_onefile.c fd994d397b0e9cad103b1a6e1f76c61a90a38752
-F src/test_osinst.c c684ee6d480f30e36cb564dcbc94f5f8467468a8
+F src/test_osinst.c acf306ba86a2963ba69dd87907fae447478a28f1
F src/test_schema.c e3f93725f7c5b2cff84a69dc4332040dfbc8f81a
F src/test_server.c 7e579eb9bf6fbe9cc45e84e4c74d3d06d049a825
F src/test_tclvar.c e99b975614735553fa1c43503d85b0dd988c0e77
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c 43277088f8fea4109a640aa46731b8752c3fb4a7
F src/vacuum.c a5c289e561ed72283e97d2485491986bc7d684eb
-F src/vdbe.c efe92d0925bc0a6f76c5bbfaf4cfee1665ae8799
-F src/vdbe.h f4bb70962d9c13e0f65b215c90e8acea1ae6e8ee
+F src/vdbe.c 37d3237ad5b84c4d4d3a33a49350c2594cac65c3
+F src/vdbe.h 1e3722d471739c2b213c6283b60373290e52f7ea
F src/vdbeInt.h ede1a31cfa74d4718f41da491bd1d2b3abc137fc
F src/vdbeapi.c 22b01ed175e4d4c613ee82cabc7a44a275641206
F src/vdbeaux.c 7823f1db7f47cf70d86d1901e2030309e1cbfd02
F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
F tool/mkkeywordhash.c ef93810fc41fb3d3dbacf9a33a29be88ea99ffa9
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
-F tool/mksqlite3c.tcl da45d6d596f536d361e428874e7071710803de1e
-F tool/mksqlite3internalh.tcl 47737a925fb02fce43e2c0a14b3cc17574a4d44a
+F tool/mksqlite3c.tcl 927b9d6ccd05690f75eb67bce7cca9a90b65ceeb
+F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
F tool/omittest.tcl 7d1fdf469e2f4d175f70c36e469db64a1626fabb
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/report1.txt 9eae07f26a8fc53889b45fc833a66a33daa22816
F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
-F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6
+F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
-F tool/speedtest8.c e74126bc12178fa29904f711bb100212a5448041
-F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854
-P ad6a782e7c408f6c3ebff5f2715c629b75c8002d
-R 486eefc4a3f966d0ff0a629a9a11c14c
-U drh
-Z 38197e0cbfc994144353080aecc69a7d
+F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
+F tool/speedtest8inst1.c c65494ca99d1e09c246dfe37a7ca7a354af9990f
+P 5f6eab65dba421a736659a6673a51a0e487d68ac
+R 458af2184cd56db6e376c81a0c3c302b
+U shane
+Z a36aff0535891ea4228fb00ae4809b6b
-5f6eab65dba421a736659a6673a51a0e487d68ac
\ No newline at end of file
+9883b406ce24eae93942ee5e6aab33fb6b05329f
\ No newline at end of file
--- /dev/null
+/*
+** 2008 May 27
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** This file contains inline asm code for retrieving "high-performance"
+** counters for x86 class CPUs.
+**
+** $Id: hwtime.h,v 1.1 2008/05/29 20:22:37 shane Exp $
+*/
+#ifndef _HWTIME_H_
+#define _HWTIME_H_
+
+/*
+** The following routine only works on pentium-class (or newer) 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.
+*/
+#if (defined(__GNUC__) || defined(_MSC_VER)) && \
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
+
+ #if defined(__GNUC__)
+
+ __inline__ sqlite_uint64 sqlite3Hwtime(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 (sqlite_uint64)hi << 32 | lo;
+ }
+
+ #elif defined(_MSC_VER)
+
+ __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
+ __asm {
+ rdtsc
+ ret ; return value at EDX:EAX
+ }
+ }
+
+ #endif
+
+#else
+
+ #error Need implementation of sqlite3Hwtime() for your platform.
+
+ /*
+ ** To compile without implementing sqlite3Hwtime() for your platform,
+ ** you can remove the above #error and use the following
+ ** stub function. You will lose timing support for many
+ ** of the debugging and testing utilities, but it should at
+ ** least compile and run.
+ */
+ sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
+
+#endif
+
+#endif /* !defined(_HWTIME_H_) */
** This file should be #included by the os_*.c files only. It is not a
** general purpose header file.
**
-** $Id: os_common.h,v 1.36 2008/05/16 04:51:55 danielk1977 Exp $
+** $Id: os_common.h,v 1.37 2008/05/29 20:22:37 shane Exp $
*/
+#ifndef _OS_COMMON_H_
+#define _OS_COMMON_H_
/*
** At least two bugs have slipped in because we changed the MEMORY_DEBUG
** on i486 hardware.
*/
#ifdef SQLITE_PERFORMANCE_TRACE
-__inline__ unsigned long long int hwtime(void){
- unsigned long long int x;
- __asm__("rdtsc\n\t"
- "mov %%edx, %%ecx\n\t"
- :"=A" (x));
- return x;
-}
-static unsigned long long int g_start;
-static unsigned int elapse;
-#define TIMER_START g_start=hwtime()
-#define TIMER_END elapse=hwtime()-g_start
-#define TIMER_ELAPSED elapse
+
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
+*/
+#include "hwtime.h"
+
+static sqlite_uint64 g_start;
+static sqlite_uint64 g_elapsed;
+#define TIMER_START g_start=sqlite3Hwtime()
+#define TIMER_END g_elapsed=sqlite3Hwtime()-g_start
+#define TIMER_ELAPSED g_elapsed
#else
#define TIMER_START
#define TIMER_END
-#define TIMER_ELAPSED 0
+#define TIMER_ELAPSED ((sqlite_uint64)0)
#endif
/*
#else
#define OpenCounter(X)
#endif
+
+#endif /* !defined(_OS_COMMON_H_) */
**
** This file contains code that is specific to Unix systems.
**
-** $Id: os_unix.c,v 1.182 2008/05/16 04:51:55 danielk1977 Exp $
+** $Id: os_unix.c,v 1.183 2008/05/29 20:22:37 shane Exp $
*/
#include "sqliteInt.h"
#if OS_UNIX /* This file is used on unix only */
got = read(id->h, pBuf, cnt);
#endif
TIMER_END;
- OSTRACE5("READ %-3d %5d %7lld %d\n", id->h, got, offset, TIMER_ELAPSED);
+ OSTRACE5("READ %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED);
return got;
}
got = write(id->h, pBuf, cnt);
#endif
TIMER_END;
- OSTRACE5("WRITE %-3d %5d %7lld %d\n", id->h, got, offset, TIMER_ELAPSED);
+ OSTRACE5("WRITE %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED);
return got;
}
** adds instrumentation to all vfs and file methods. C and Tcl interfaces
** are provided to control the instrumentation.
**
-** $Id: test_osinst.c,v 1.11 2008/05/16 04:51:55 danielk1977 Exp $
+** $Id: test_osinst.c,v 1.12 2008/05/29 20:22:37 shane Exp $
*/
/*
**
** * The name of the invoked method - i.e. "xRead".
**
-** * The time consumed by the method call as measured by hwtime() (an
-** integer value)
+** * The time consumed by the method call as measured by
+** sqlite3Hwtime() (an integer value)
**
** * A string value with a different meaning for different calls.
** For file methods, the name of the file being operated on. For
** * The name of the method call - i.e. "xWrite",
** * The total number of calls to the method (an integer).
** * The aggregate time consumed by all calls to the method as
-** measured by hwtime() (an integer).
+** measured by sqlite3Hwtime() (an integer).
*/
#include "sqlite3.h"
instDeviceCharacteristics /* xDeviceCharacteristics */
};
-/*
-** 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.
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
*/
-#if defined(i386) || defined(__i386__) || defined(_M_IX86)
-__inline__ unsigned long long int osinst_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;
-}
-#else
- static unsigned long long int osinst_hwtime(void){ return 0; }
-#endif
+#include "hwtime.h"
#define OS_TIME_IO(eEvent, A, B, Call) { \
inst_file *p = (inst_file *)pFile; \
InstVfs *pInstVfs = p->pInstVfs; \
int rc; \
- sqlite3_int64 t = osinst_hwtime(); \
+ sqlite_uint64 t = sqlite3Hwtime(); \
rc = Call; \
- t = osinst_hwtime() - t; \
+ t = sqlite3Hwtime() - t; \
pInstVfs->aTime[eEvent] += t; \
pInstVfs->aCount[eEvent] += 1; \
if( pInstVfs->xCall ){ \
#define OS_TIME_VFS(eEvent, Z, flags, A, B, Call) { \
InstVfs *pInstVfs = (InstVfs *)pVfs; \
int rc; \
- sqlite3_int64 t = osinst_hwtime(); \
+ sqlite_uint64 t = sqlite3Hwtime(); \
rc = Call; \
- t = osinst_hwtime() - t; \
+ t = sqlite3Hwtime() - t; \
pInstVfs->aTime[eEvent] += t; \
pInstVfs->aCount[eEvent] += 1; \
if( pInstVfs->xCall ){ \
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.743 2008/05/29 05:23:42 drh Exp $
+** $Id: vdbe.c,v 1.744 2008/05/29 20:22:37 shane Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#ifdef VDBE_PROFILE
-/*
-** 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;
-}
+
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
+*/
+#include "hwtime.h"
+
#endif
/*
Mem *pOut; /* Output operand */
u8 opProperty;
#ifdef VDBE_PROFILE
- unsigned long long start; /* CPU clock count at start of opcode */
+ u64 start; /* CPU clock count at start of opcode */
int origPc; /* Program counter at start of opcode */
#endif
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
if( db->mallocFailed ) goto no_mem;
#ifdef VDBE_PROFILE
origPc = pc;
- start = hwtime();
+ start = sqlite3Hwtime();
#endif
pOp = &p->aOp[pc];
#ifdef VDBE_PROFILE
{
- long long elapse = hwtime() - start;
- pOp->cycles += elapse;
+ u64 elapsed = sqlite3Hwtime() - start;
+ pOp->cycles += elapsed;
pOp->cnt++;
#if 0
- fprintf(stdout, "%10lld ", elapse);
+ fprintf(stdout, "%10llu ", elapsed);
sqlite3VdbePrintOp(stdout, origPc, &p->aOp[origPc]);
#endif
}
** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database.
**
-** $Id: vdbe.h,v 1.131 2008/05/01 17:03:49 drh Exp $
+** $Id: vdbe.h,v 1.132 2008/05/29 20:22:37 shane Exp $
*/
#ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
} p4;
#ifdef SQLITE_DEBUG
- char *zComment; /* Comment to improve readability */
+ char *zComment; /* Comment to improve readability */
#endif
#ifdef VDBE_PROFILE
- int cnt; /* Number of times this instruction was executed */
- long long cycles; /* Total time spend executing this instruction */
+ int cnt; /* Number of times this instruction was executed */
+ u64 cycles; /* Total time spent executing this instruction */
#endif
};
typedef struct VdbeOp VdbeOp;
fts3_hash.h
fts3_tokenizer.h
hash.h
+ hwtime.h
keywordhash.h
mutex.h
opcodes.h
if {[regexp {^#\s*include\s+["<]([^">]+)[">]} $line all hdr]} {
if {[info exists available_hdr($hdr)]} {
if {$available_hdr($hdr)} {
- if {$hdr!="os_common.h"} {
+ if {$hdr!="os_common.h" && $hdr!="hwtime.h"} {
set available_hdr($hdr) 0
}
section_comment "Include $hdr in the middle of $tail"
bitvec.c
pager.c
- btmutex.c
+ btmutex.c
btree.c
vdbefifo.c
btree.h
btreeInt.h
hash.h
+ hwtime.h
keywordhash.h
opcodes.h
os_common.h
** Then link against this program. But to do optimize this program
** because that defeats the hi-res timer.
**
-** gcc speedtest16.c sqlite3.o -ldl
+** gcc speedtest16.c sqlite3.o -ldl -I../src
**
** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test:
#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.
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
*/
-__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;
-}
+#include "hwtime.h"
/*
** Convert a zero-terminated ASCII string into a zero-terminated
/*
** Timers
*/
-static unsigned long long int prepTime = 0;
-static unsigned long long int runTime = 0;
-static unsigned long long int finalizeTime = 0;
+static sqlite_uint64 prepTime = 0;
+static sqlite_uint64 runTime = 0;
+static sqlite_uint64 finalizeTime = 0;
/*
** Prepare and run a single statement of SQL.
void *utf16;
sqlite3_stmt *pStmt;
const void *stmtTail;
- unsigned long long int iStart, iElapse;
+ sqlite_uint64 iStart, iElapse;
int rc;
printf("****************************************************************\n");
printf("SQL statement: [%s]\n", zSql);
utf16 = asciiToUtf16le(zSql);
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_prepare16_v2(db, utf16, -1, &pStmt, &stmtTail);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
prepTime += iElapse;
printf("sqlite3_prepare16_v2() returns %d in %llu cycles\n", rc, iElapse);
if( rc==SQLITE_OK ){
int nRow = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
runTime += iElapse;
printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
rc, nRow, iElapse);
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_finalize(pStmt);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
finalizeTime += iElapse;
printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
}
char *zSql;
int i, j;
FILE *in;
- unsigned long long int iStart, iElapse;
- unsigned long long int iSetup = 0;
+ sqlite_uint64 iStart, iElapse;
+ sqlite_uint64 iSetup = 0;
int nStmt = 0;
int nByte = 0;
printf("SQLite version: %d\n", sqlite3_libversion_number());
unlink(argv[1]);
utf16 = asciiToUtf16le(argv[1]);
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_open16(utf16, &db);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
iSetup = iElapse;
printf("sqlite3_open16() returns %d in %llu cycles\n", rc, iElapse);
free(utf16);
}
}
}
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
sqlite3_close(db);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
iSetup += iElapse;
printf("sqlite3_close() returns in %llu cycles\n", iElapse);
printf("\n");
** Then link against this program. But to do optimize this program
** because that defeats the hi-res timer.
**
-** gcc speedtest8.c sqlite3.o -ldl
+** gcc speedtest8.c sqlite3.o -ldl -I../src
**
** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test:
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#include <time.h>
+
+#if defined(_MSC_VER)
+#include <windows.h>
+#else
#include <unistd.h>
#include <sys/times.h>
-#include <time.h>
#include <sched.h>
+#endif
#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.
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
*/
-__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;
-}
+#include "hwtime.h"
/*
** Timers
*/
-static unsigned long long int prepTime = 0;
-static unsigned long long int runTime = 0;
-static unsigned long long int finalizeTime = 0;
+static sqlite_uint64 prepTime = 0;
+static sqlite_uint64 runTime = 0;
+static sqlite_uint64 finalizeTime = 0;
/*
** Prepare and run a single statement of SQL.
static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){
sqlite3_stmt *pStmt;
const char *stmtTail;
- unsigned long long int iStart, iElapse;
+ sqlite_uint64 iStart, iElapse;
int rc;
if (!bQuiet){
printf("***************************************************************\n");
}
if (!bQuiet) printf("SQL statement: [%s]\n", zSql);
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
prepTime += iElapse;
if (!bQuiet){
printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);
}
if( rc==SQLITE_OK ){
int nRow = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
runTime += iElapse;
if (!bQuiet){
printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
rc, nRow, iElapse);
}
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_finalize(pStmt);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
finalizeTime += iElapse;
if (!bQuiet){
printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
char *zSql;
int i, j;
FILE *in;
- unsigned long long int iStart, iElapse;
- unsigned long long int iSetup = 0;
+ sqlite_uint64 iStart, iElapse;
+ sqlite_uint64 iSetup = 0;
int nStmt = 0;
int nByte = 0;
const char *zArgv0 = argv[0];
int bQuiet = 0;
+#if !defined(_MSC_VER)
struct tms tmsStart, tmsEnd;
clock_t clkStart, clkEnd;
+#endif
#ifdef HAVE_OSINST
extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *);
** equates to "Normal".
*/
if( argc>4 && (strcmp(argv[1], "-priority")==0) ){
+#if defined(_MSC_VER)
+ int new_priority = atoi(argv[2]);
+ if(!SetPriorityClass(GetCurrentProcess(),
+ (new_priority<=-5) ? HIGH_PRIORITY_CLASS :
+ (new_priority<=0) ? ABOVE_NORMAL_PRIORITY_CLASS :
+ (new_priority==0) ? NORMAL_PRIORITY_CLASS :
+ (new_priority<5) ? BELOW_NORMAL_PRIORITY_CLASS :
+ IDLE_PRIORITY_CLASS)){
+ printf ("error setting priority\n");
+ exit(2);
+ }
+#else
struct sched_param myParam;
sched_getparam(0, &myParam);
printf ("Current process priority is %d.\n", (int)myParam.sched_priority);
printf ("error setting priority\n");
exit(2);
}
+#endif
argv += 2;
argc -= 2;
continue;
printf("SQLite version: %d\n", sqlite3_libversion_number());
unlink(argv[1]);
+#if !defined(_MSC_VER)
clkStart = times(&tmsStart);
- iStart = hwtime();
+#endif
+ iStart = sqlite3Hwtime();
rc = sqlite3_open(argv[1], &db);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
iSetup = iElapse;
if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
for(i=j=0; j<nSql; j++){
}
}
}
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
sqlite3_close(db);
- iElapse = hwtime() - iStart;
+ iElapse = sqlite3Hwtime() - iStart;
+#if !defined(_MSC_VER)
clkEnd = times(&tmsEnd);
+#endif
iSetup += iElapse;
if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse);
printf("Total time: %15llu cycles\n",
prepTime + runTime + finalizeTime + iSetup);
+#if !defined(_MSC_VER)
printf("\n");
printf("Total user CPU time: %15.3g secs\n", (tmsEnd.tms_utime - tmsStart.tms_utime)/(double)CLOCKS_PER_SEC );
printf("Total system CPU time: %15.3g secs\n", (tmsEnd.tms_stime - tmsStart.tms_stime)/(double)CLOCKS_PER_SEC );
printf("Total real time: %15.3g secs\n", (clkEnd -clkStart)/(double)CLOCKS_PER_SEC );
+#endif
#ifdef HAVE_OSINST
if( pVfs ){
** Then link against this program. But to do optimize this program
** because that defeats the hi-res timer.
**
-** gcc speedtest8.c sqlite3.o -ldl
+** gcc speedtest8.c sqlite3.o -ldl -I../src
**
** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test:
#include <stdarg.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__ sqlite3_uint64 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 (sqlite3_uint64)hi << 32 | lo;
-}
+/*
+** hwtime.h contains inline assembler code for implementing
+** high-performance timing routines.
+*/
+#include "hwtime.h"
/*
** Send a message to the log file.
};
#define OS_TIME_IO(MESSAGE, A, B, CALL) \
- int rc; sqlite3_uint64 t1, t2; \
+ int rc; \
+ sqlite_uint64 t1, t2; \
inst_file *p = (inst_file*)pFile; \
- t1 = hwtime(); \
+ t1 = sqlite3Hwtime(); \
rc = CALL; \
- t2 = hwtime(); \
+ t2 = sqlite3Hwtime(); \
logMessage(MESSAGE, A, B, t2-t1); \
- instTime += hwtime() - t2; \
+ instTime += sqlite3Hwtime() - t2; \
return rc;
#define OS_TIME_VFS(MESSAGE, A, B, CALL) \
int rc; \
- sqlite3_uint64 t1, t2; \
+ sqlite_uint64 t1, t2; \
sqlite3_vfs *pRealVfs = (sqlite3_vfs*)pVfs->pAppData; \
- t1 = hwtime(); \
+ t1 = sqlite3Hwtime(); \
rc = CALL; \
- t2 = hwtime(); \
+ t2 = sqlite3Hwtime(); \
logMessage(MESSAGE, A, B, t2-t1); \
- instTime += hwtime() - t2; \
+ instTime += sqlite3Hwtime() - t2; \
return rc;
static void prepareAndRun(sqlite3 *db, const char *zSql){
sqlite3_stmt *pStmt;
const char *stmtTail;
- sqlite3_uint64 iStart, iElapse;
+ sqlite_uint64 iStart, iElapse;
int rc;
printf("****************************************************************\n");
printf("SQL statement: [%s]\n", zSql);
instTime = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);
- iElapse = hwtime();
+ iElapse = sqlite3Hwtime();
iElapse -= iStart + instTime;
prepTime += iElapse;
printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);
if( rc==SQLITE_OK ){
int nRow = 0;
instTime = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }
- iElapse = hwtime();
+ iElapse = sqlite3Hwtime();
iElapse -= iStart + instTime;
runTime += iElapse;
printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
rc, nRow, iElapse);
instTime = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_finalize(pStmt);
- iElapse = hwtime();
+ iElapse = sqlite3Hwtime();
iElapse -= iStart + instTime;
finalizeTime += iElapse;
printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
char *zSql;
int i, j;
FILE *in;
- sqlite3_uint64 iStart, iElapse;
- sqlite3_uint64 iSetup = 0;
+ sqlite_uint64 iStart, iElapse;
+ sqlite_uint64 iSetup = 0;
int nStmt = 0;
int nByte = 0;
unlink(argv[1]);
setupInstrumentedVfs();
instTime = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
rc = sqlite3_open(argv[1], &db);
- iElapse = hwtime();
+ iElapse = sqlite3Hwtime();
iElapse -= iStart + instTime;
iSetup = iElapse;
printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
}
}
instTime = 0;
- iStart = hwtime();
+ iStart = sqlite3Hwtime();
sqlite3_close(db);
- iElapse = hwtime();
+ iElapse = sqlite3Hwtime();
iElapse -= iStart + instTime;
iSetup += iElapse;
printf("sqlite3_close() returns in %llu cycles\n", iElapse);