1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Changes speedtest8 and speedtest16 so that the database file can be specified

on the command-line.  Allows speed testing against a :memory: database. (CVS 4960)

FossilOrigin-Name: 64badc50531668de45d76a3dcd90db17e1fe1ab1
This commit is contained in:
drh
2008-04-03 17:57:24 +00:00
parent fb103a8488
commit 17afdd238f
4 changed files with 33 additions and 23 deletions

View File

@ -20,7 +20,7 @@
** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test:
**
** ./a.out test.sql
** ./a.out database.db test.sql
*/
#include <stdio.h>
#include <string.h>
@ -112,14 +112,16 @@ int main(int argc, char **argv){
FILE *in;
unsigned long long int iStart, iElapse;
unsigned long long int iSetup = 0;
int nStmt = 0;
int nByte = 0;
if( argc!=2 ){
fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
if( argc!=3 ){
fprintf(stderr, "Usage: %s FILENAME SQL-SCRIPT\n"
"Runs SQL-SCRIPT as UTF16 against a UTF16 database\n",
argv[0]);
exit(1);
}
in = fopen(argv[1], "r");
in = fopen(argv[2], "r");
fseek(in, 0L, SEEK_END);
nSql = ftell(in);
zSql = malloc( nSql+1 );
@ -128,9 +130,8 @@ int main(int argc, char **argv){
zSql[nSql] = 0;
printf("SQLite version: %d\n", sqlite3_libversion_number());
unlink("test.db");
unlink("test.db-journal");
utf16 = asciiToUtf16le("test.db");
unlink(argv[1]);
utf16 = asciiToUtf16le(argv[1]);
iStart = hwtime();
rc = sqlite3_open16(utf16, &db);
iElapse = hwtime() - iStart;
@ -148,6 +149,8 @@ int main(int argc, char **argv){
zSql[j] = 0;
while( i<j && isspace(zSql[i]) ){ i++; }
if( i<j ){
nStmt++;
nByte += j-i;
prepareAndRun(db, &zSql[i]);
}
zSql[j] = ';';
@ -161,6 +164,8 @@ int main(int argc, char **argv){
iSetup += iElapse;
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);

View File

@ -19,7 +19,7 @@
** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test:
**
** ./a.out test.sql
** ./a.out test.db test.sql
*/
#include <stdio.h>
#include <string.h>
@ -89,14 +89,16 @@ int main(int argc, char **argv){
FILE *in;
unsigned long long int iStart, iElapse;
unsigned long long int iSetup = 0;
int nStmt = 0;
int nByte = 0;
if( argc!=2 ){
fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
if( argc!=3 ){
fprintf(stderr, "Usage: %s FILENAME SQL-SCRIPT\n"
"Runs SQL-SCRIPT against a UTF8 database\n",
argv[0]);
exit(1);
}
in = fopen(argv[1], "r");
in = fopen(argv[2], "r");
fseek(in, 0L, SEEK_END);
nSql = ftell(in);
zSql = malloc( nSql+1 );
@ -105,10 +107,9 @@ int main(int argc, char **argv){
zSql[nSql] = 0;
printf("SQLite version: %d\n", sqlite3_libversion_number());
unlink("test.db");
unlink("test.db-journal");
unlink(argv[1]);
iStart = hwtime();
rc = sqlite3_open("test.db", &db);
rc = sqlite3_open(argv[1], &db);
iElapse = hwtime() - iStart;
iSetup = iElapse;
printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
@ -123,6 +124,8 @@ int main(int argc, char **argv){
zSql[j] = 0;
while( i<j && isspace(zSql[i]) ){ i++; }
if( i<j ){
nStmt++;
nByte += j-i;
prepareAndRun(db, &zSql[i]);
}
zSql[j] = ';';
@ -136,6 +139,8 @@ int main(int argc, char **argv){
iSetup += iElapse;
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);