/ Check-in [64badc50]
Login

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

Overview
Comment: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)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 64badc50531668de45d76a3dcd90db17e1fe1ab1
User & Date: drh 2008-04-03 17:57:25
Context
2008-04-03
19:40
Use an improved RDTSC access routine. (CVS 4961) check-in: b4eba9c5 user: drh tags: trunk
17:57
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) check-in: 64badc50 user: drh tags: trunk
16:28
Instead of calling sqlite3_exec() to evaluate "PRAGMA encoding = UTF16" in sqlite3_open16(), set the connection encoding flag directly. (CVS 4959) check-in: 33a12e73 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/speedtest16.c.

    16     16   ** because that defeats the hi-res timer.
    17     17   **
    18     18   **     gcc speedtest16.c sqlite3.o -ldl
    19     19   **
    20     20   ** Then run this program with a single argument which is the name of
    21     21   ** a file containing SQL script that you want to test:
    22     22   **
    23         -**     ./a.out test.sql
           23  +**     ./a.out database.db test.sql
    24     24   */
    25     25   #include <stdio.h>
    26     26   #include <string.h>
    27     27   #include <stdlib.h>
    28     28   #include "sqlite3.h"
    29     29   
    30     30   
................................................................................
   108    108     int rc;
   109    109     int nSql;
   110    110     char *zSql;
   111    111     int i, j;
   112    112     FILE *in;
   113    113     unsigned long long int iStart, iElapse;
   114    114     unsigned long long int iSetup = 0;
          115  +  int nStmt = 0;
          116  +  int nByte = 0;
   115    117   
   116         -  if( argc!=2 ){
   117         -    fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
          118  +  if( argc!=3 ){
          119  +    fprintf(stderr, "Usage: %s FILENAME SQL-SCRIPT\n"
   118    120                       "Runs SQL-SCRIPT as UTF16 against a UTF16 database\n",
   119    121                       argv[0]);
   120    122       exit(1);
   121    123     }
   122         -  in = fopen(argv[1], "r");
          124  +  in = fopen(argv[2], "r");
   123    125     fseek(in, 0L, SEEK_END);
   124    126     nSql = ftell(in);
   125    127     zSql = malloc( nSql+1 );
   126    128     fseek(in, 0L, SEEK_SET);
   127    129     nSql = fread(zSql, 1, nSql, in);
   128    130     zSql[nSql] = 0;
   129    131   
   130    132     printf("SQLite version: %d\n", sqlite3_libversion_number());
   131         -  unlink("test.db");
   132         -  unlink("test.db-journal");
   133         -  utf16 = asciiToUtf16le("test.db");
          133  +  unlink(argv[1]);
          134  +  utf16 = asciiToUtf16le(argv[1]);
   134    135     iStart = hwtime();
   135    136     rc = sqlite3_open16(utf16, &db);
   136    137     iElapse = hwtime() - iStart;
   137    138     iSetup = iElapse;
   138    139     printf("sqlite3_open16() returns %d in %llu cycles\n", rc, iElapse);
   139    140     free(utf16);
   140    141     for(i=j=0; j<nSql; j++){
................................................................................
   144    145         zSql[j+1] = 0;
   145    146         isComplete = sqlite3_complete(&zSql[i]);
   146    147         zSql[j+1] = c;
   147    148         if( isComplete ){
   148    149           zSql[j] = 0;
   149    150           while( i<j && isspace(zSql[i]) ){ i++; }
   150    151           if( i<j ){
          152  +          nStmt++;
          153  +          nByte += j-i;
   151    154             prepareAndRun(db, &zSql[i]);
   152    155           }
   153    156           zSql[j] = ';';
   154    157           i = j+1;
   155    158         }
   156    159       }
   157    160     }
   158    161     iStart = hwtime();
   159    162     sqlite3_close(db);
   160    163     iElapse = hwtime() - iStart;
   161    164     iSetup += iElapse;
   162    165     printf("sqlite3_close() returns in %llu cycles\n", iElapse);
   163    166     printf("\n");
          167  +  printf("Statements run:       %15d\n", nStmt);
          168  +  printf("Bytes of SQL text:    %15d\n", nByte);
   164    169     printf("Total prepare time:   %15llu cycles\n", prepTime);
   165    170     printf("Total run time:       %15llu cycles\n", runTime);
   166    171     printf("Total finalize time:  %15llu cycles\n", finalizeTime);
   167    172     printf("Open/Close time:      %15llu cycles\n", iSetup);
   168    173     printf("Total Time:           %15llu cycles\n",
   169    174         prepTime + runTime + finalizeTime + iSetup);
   170    175     return 0;
   171    176   }

Changes to tool/speedtest8.c.

    15     15   ** because that defeats the hi-res timer.
    16     16   **
    17     17   **     gcc speedtest8.c sqlite3.o -ldl
    18     18   **
    19     19   ** Then run this program with a single argument which is the name of
    20     20   ** a file containing SQL script that you want to test:
    21     21   **
    22         -**     ./a.out test.sql
           22  +**     ./a.out test.db  test.sql
    23     23   */
    24     24   #include <stdio.h>
    25     25   #include <string.h>
    26     26   #include <stdlib.h>
    27     27   #include "sqlite3.h"
    28     28   
    29     29   
................................................................................
    85     85     int rc;
    86     86     int nSql;
    87     87     char *zSql;
    88     88     int i, j;
    89     89     FILE *in;
    90     90     unsigned long long int iStart, iElapse;
    91     91     unsigned long long int iSetup = 0;
           92  +  int nStmt = 0;
           93  +  int nByte = 0;
    92     94   
    93         -  if( argc!=2 ){
    94         -    fprintf(stderr, "Usage: %s SQL-SCRIPT\n"
           95  +  if( argc!=3 ){
           96  +    fprintf(stderr, "Usage: %s FILENAME SQL-SCRIPT\n"
    95     97                       "Runs SQL-SCRIPT against a UTF8 database\n",
    96     98                       argv[0]);
    97     99       exit(1);
    98    100     }
    99         -  in = fopen(argv[1], "r");
          101  +  in = fopen(argv[2], "r");
   100    102     fseek(in, 0L, SEEK_END);
   101    103     nSql = ftell(in);
   102    104     zSql = malloc( nSql+1 );
   103    105     fseek(in, 0L, SEEK_SET);
   104    106     nSql = fread(zSql, 1, nSql, in);
   105    107     zSql[nSql] = 0;
   106    108   
   107    109     printf("SQLite version: %d\n", sqlite3_libversion_number());
   108         -  unlink("test.db");
   109         -  unlink("test.db-journal");
          110  +  unlink(argv[1]);
   110    111     iStart = hwtime();
   111         -  rc = sqlite3_open("test.db", &db);
          112  +  rc = sqlite3_open(argv[1], &db);
   112    113     iElapse = hwtime() - iStart;
   113    114     iSetup = iElapse;
   114    115     printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
   115    116     for(i=j=0; j<nSql; j++){
   116    117       if( zSql[j]==';' ){
   117    118         int isComplete;
   118    119         char c = zSql[j+1];
................................................................................
   119    120         zSql[j+1] = 0;
   120    121         isComplete = sqlite3_complete(&zSql[i]);
   121    122         zSql[j+1] = c;
   122    123         if( isComplete ){
   123    124           zSql[j] = 0;
   124    125           while( i<j && isspace(zSql[i]) ){ i++; }
   125    126           if( i<j ){
          127  +          nStmt++;
          128  +          nByte += j-i;
   126    129             prepareAndRun(db, &zSql[i]);
   127    130           }
   128    131           zSql[j] = ';';
   129    132           i = j+1;
   130    133         }
   131    134       }
   132    135     }
   133    136     iStart = hwtime();
   134    137     sqlite3_close(db);
   135    138     iElapse = hwtime() - iStart;
   136    139     iSetup += iElapse;
   137    140     printf("sqlite3_close() returns in %llu cycles\n", iElapse);
   138    141     printf("\n");
          142  +  printf("Statements run:       %15d\n", nStmt);
          143  +  printf("Bytes of SQL text:    %15d\n", nByte);
   139    144     printf("Total prepare time:   %15llu cycles\n", prepTime);
   140    145     printf("Total run time:       %15llu cycles\n", runTime);
   141    146     printf("Total finalize time:  %15llu cycles\n", finalizeTime);
   142    147     printf("Open/Close time:      %15llu cycles\n", iSetup);
   143    148     printf("Total Time:           %15llu cycles\n",
   144    149         prepTime + runTime + finalizeTime + iSetup);
   145    150     return 0;
   146    151   }