mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Improved option handling in speedtest8.c. Added -quiet and -priority options. Added reporting of total user and system time. (CVS 5070)
FossilOrigin-Name: aa59974ec15508d69c5b65ab89ec7bc32690018c
This commit is contained in:
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\stest\sfor\sbuffer\soverrun\sin\sunixGettempname().\sFix\sfor\s#3091.\s(CVS\s5069)
|
||||
D 2008-04-30T08:56:10
|
||||
C Improved\soption\shandling\sin\sspeedtest8.c.\s\sAdded\s-quiet\sand\s-priority\soptions.\s\sAdded\sreporting\sof\stotal\suser\sand\ssystem\stime.\s(CVS\s5070)
|
||||
D 2008-04-30T15:55:34
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -573,7 +573,7 @@ F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39
|
||||
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
|
||||
F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c fd53bf13c7bbea4671faa2222cbb3286c14200f8
|
||||
F tool/speedtest8.c a7cd2b2dbb8f97b0c51c0e01f49116a9162071be
|
||||
F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854
|
||||
F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20
|
||||
F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
|
||||
@ -633,7 +633,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P f854ae576ee0b223b86a1169178fc4399e8d08ce
|
||||
R dc0d12af7248df7518eb5354b7eeb383
|
||||
U danielk1977
|
||||
Z 6533bd0cfc41b7cb37a38e5960f73499
|
||||
P fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34
|
||||
R 8bd12bf8a3eaadb4e117c1f015393938
|
||||
U shane
|
||||
Z 09702a98c8183287a6fdc49d86797b33
|
||||
|
@ -1 +1 @@
|
||||
fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34
|
||||
aa59974ec15508d69c5b65ab89ec7bc32690018c
|
@ -26,8 +26,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include "sqlite3.h"
|
||||
#include <sys/times.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** The following routine only works on pentium-class processors.
|
||||
@ -52,32 +55,32 @@ static unsigned long long int finalizeTime = 0;
|
||||
/*
|
||||
** Prepare and run a single statement of SQL.
|
||||
*/
|
||||
static void prepareAndRun(sqlite3 *db, const char *zSql){
|
||||
static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){
|
||||
sqlite3_stmt *pStmt;
|
||||
const char *stmtTail;
|
||||
unsigned long long int iStart, iElapse;
|
||||
int rc;
|
||||
|
||||
printf("****************************************************************\n");
|
||||
printf("SQL statement: [%s]\n", zSql);
|
||||
if (!bQuiet) printf("****************************************************************\n");
|
||||
if (!bQuiet) printf("SQL statement: [%s]\n", zSql);
|
||||
iStart = hwtime();
|
||||
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);
|
||||
iElapse = hwtime() - iStart;
|
||||
prepTime += iElapse;
|
||||
printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);
|
||||
if (!bQuiet) printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);
|
||||
if( rc==SQLITE_OK ){
|
||||
int nRow = 0;
|
||||
iStart = hwtime();
|
||||
while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }
|
||||
iElapse = hwtime() - iStart;
|
||||
runTime += iElapse;
|
||||
printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
|
||||
if (!bQuiet) printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
|
||||
rc, nRow, iElapse);
|
||||
iStart = hwtime();
|
||||
rc = sqlite3_finalize(pStmt);
|
||||
iElapse = hwtime() - iStart;
|
||||
finalizeTime += iElapse;
|
||||
printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
|
||||
if (!bQuiet) printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,6 +179,9 @@ int main(int argc, char **argv){
|
||||
int nStmt = 0;
|
||||
int nByte = 0;
|
||||
const char *zArgv0 = argv[0];
|
||||
int bQuiet = 0;
|
||||
struct tms tmsStart, tmsEnd;
|
||||
clock_t clkStart, clkEnd;
|
||||
|
||||
#ifdef HAVE_OSINST
|
||||
extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *);
|
||||
@ -183,32 +189,67 @@ int main(int argc, char **argv){
|
||||
sqlite3_vfs *pVfs = 0;
|
||||
#endif
|
||||
|
||||
if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){
|
||||
registerOverwriteVfs();
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
while (argc>3)
|
||||
{
|
||||
if( argc>3 && strcmp(argv[1], "-overwrite")==0 ){
|
||||
registerOverwriteVfs();
|
||||
argv++;
|
||||
argc--;
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OSINST
|
||||
if( argc>=5 && strcmp(argv[1], "-log")==0 ){
|
||||
pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]);
|
||||
sqlite3_vfs_register(pVfs, 1);
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
}
|
||||
if( argc>4 && (strcmp(argv[1], "-log")==0) ){
|
||||
pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]);
|
||||
sqlite3_vfs_register(pVfs, 1);
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( argc>=4 && strcmp(argv[1], "-overwrite")==0 ){
|
||||
registerOverwriteVfs();
|
||||
argv++;
|
||||
argc--;
|
||||
/*
|
||||
** Increasing the priority slightly above normal can help with repeatability
|
||||
** of testing. Note that with Cygwin, -5 equates to "High", +5 equates to "Low",
|
||||
** and anything in between equates to "Normal".
|
||||
*/
|
||||
if( argc>4 && (strcmp(argv[1], "-priority")==0) ){
|
||||
struct sched_param myParam;
|
||||
sched_getparam(0, &myParam);
|
||||
printf ("Current process priority is %d.\n", (int)myParam.sched_priority);
|
||||
myParam.sched_priority = atoi(argv[2]);
|
||||
printf ("Setting process priority to %d.\n", (int)myParam.sched_priority);
|
||||
if (sched_setparam (0, &myParam) != 0){
|
||||
printf ("error setting priority\n");
|
||||
exit(2);
|
||||
}
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( argc>3 && strcmp(argv[1], "-quiet")==0 ){
|
||||
bQuiet = -1;
|
||||
argv++;
|
||||
argc--;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if( argc!=3 ){
|
||||
fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n"
|
||||
"Runs SQL-SCRIPT against a UTF8 database\n",
|
||||
zArgv0);
|
||||
exit(1);
|
||||
fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n"
|
||||
"Runs SQL-SCRIPT against a UTF8 database\n"
|
||||
"\toptions:\n"
|
||||
"\t-overwrite\n"
|
||||
#ifdef HAVE_OSINST
|
||||
"\t-log <log>\n"
|
||||
#endif
|
||||
"\t-priority <value> : set priority of task\n"
|
||||
"\t-quiet : only display summary results\n",
|
||||
zArgv0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
in = fopen(argv[2], "r");
|
||||
@ -221,11 +262,12 @@ int main(int argc, char **argv){
|
||||
|
||||
printf("SQLite version: %d\n", sqlite3_libversion_number());
|
||||
unlink(argv[1]);
|
||||
clkStart = times(&tmsStart);
|
||||
iStart = hwtime();
|
||||
rc = sqlite3_open(argv[1], &db);
|
||||
iElapse = hwtime() - iStart;
|
||||
iSetup = iElapse;
|
||||
printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
|
||||
if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
|
||||
for(i=j=0; j<nSql; j++){
|
||||
if( zSql[j]==';' ){
|
||||
int isComplete;
|
||||
@ -241,7 +283,7 @@ int main(int argc, char **argv){
|
||||
if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1);
|
||||
nStmt++;
|
||||
nByte += n;
|
||||
prepareAndRun(db, &zSql[i]);
|
||||
prepareAndRun(db, &zSql[i], bQuiet);
|
||||
}
|
||||
zSql[j] = ';';
|
||||
i = j+1;
|
||||
@ -251,18 +293,25 @@ int main(int argc, char **argv){
|
||||
iStart = hwtime();
|
||||
sqlite3_close(db);
|
||||
iElapse = hwtime() - iStart;
|
||||
clkEnd = times(&tmsEnd);
|
||||
iSetup += iElapse;
|
||||
printf("sqlite3_close() returns in %llu cycles\n", iElapse);
|
||||
if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse);
|
||||
|
||||
printf("\n");
|
||||
printf("Statements run: %15d\n", nStmt);
|
||||
printf("Bytes of SQL text: %15d\n", nByte);
|
||||
printf("Total prepare time: %15llu cycles\n", prepTime);
|
||||
printf("Total run time: %15llu cycles\n", runTime);
|
||||
printf("Total finalize time: %15llu cycles\n", finalizeTime);
|
||||
printf("Open/Close time: %15llu cycles\n", iSetup);
|
||||
printf("Total Time: %15llu cycles\n",
|
||||
printf("Statements run: %15d stmts\n", nStmt);
|
||||
printf("Bytes of SQL text: %15d bytes\n", nByte);
|
||||
printf("Total prepare time: %15llu cycles\n", prepTime);
|
||||
printf("Total run time: %15llu cycles\n", runTime);
|
||||
printf("Total finalize time: %15llu cycles\n", finalizeTime);
|
||||
printf("Open/Close time: %15llu cycles\n", iSetup);
|
||||
printf("Total time: %15llu cycles\n",
|
||||
prepTime + runTime + finalizeTime + iSetup);
|
||||
|
||||
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 );
|
||||
|
||||
#ifdef HAVE_OSINST
|
||||
if( pVfs ){
|
||||
sqlite3_instvfs_destroy(pVfs);
|
||||
|
Reference in New Issue
Block a user