/ Check-in [34a722a2]
Login

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

Overview
Comment:Improvements to fuzzershell: Avoid excess memory allocations when loading many files. Show the total runtime on final output. Show individual filenames as they are processed even if they are single test-case files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 34a722a2f3331c35211526c9ec055d4d9175c965
User & Date: drh 2015-05-02 19:54:35
Context
2015-05-04
12:29
Add the 'y' flag to the fts3/4 matchinfo() function. check-in: aef1e8f4 user: dan tags: trunk
2015-05-02
19:54
Improvements to fuzzershell: Avoid excess memory allocations when loading many files. Show the total runtime on final output. Show individual filenames as they are processed even if they are single test-case files. check-in: 34a722a2 user: drh tags: trunk
17:40
Add the ".limit" command to the command-line shell. check-in: 803cb60e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/fuzzershell.c.

   447    447     int oomCnt = 0;               /* Counter for the OOM loop */
   448    448     char zErrBuf[200];            /* Space for the error message */
   449    449     const char *zFailCode;        /* Value of the TEST_FAILURE environment var */
   450    450     const char *zPrompt;          /* Initial prompt when large-file fuzzing */
   451    451     int nInFile = 0;              /* Number of input files to read */
   452    452     char **azInFile = 0;          /* Array of input file names */
   453    453     int jj;                       /* Loop counter for azInFile[] */
          454  +  sqlite3_int64 iBegin;         /* Start time for the whole program */
   454    455     sqlite3_int64 iStart, iEnd;   /* Start and end-times for a test case */
   455    456   
   456         -
          457  +  iBegin = timeOfDay();
   457    458     zFailCode = getenv("TEST_FAILURE");
   458    459     g.zArgv0 = argv[0];
   459    460     zPrompt = "<stdin>";
   460    461     for(i=1; i<argc; i++){
   461    462       const char *z = argv[i];
   462    463       if( z[0]=='-' ){
   463    464         z++;
................................................................................
   608    609         for(j=k=0; zPrompt[j]; j++) if( zPrompt[j]=='/' ) k = j+1;
   609    610         zPrompt += k;
   610    611       }else{
   611    612         in = stdin;
   612    613         zPrompt = "<stdin>";
   613    614       }
   614    615       while( !feof(in) ){
   615         -      zIn = realloc(zIn, nAlloc);
   616         -      if( zIn==0 ) fatalError("out of memory");
   617    616         got = fread(zIn+nIn, 1, nAlloc-nIn-1, in); 
   618    617         nIn += (int)got;
   619    618         zIn[nIn] = 0;
   620    619         if( got==0 ) break;
   621         -      nAlloc += nAlloc+1000;
          620  +      if( nAlloc - nIn - 1 < 100 ){
          621  +        nAlloc += nAlloc+1000;
          622  +        zIn = realloc(zIn, nAlloc);
          623  +        if( zIn==0 ) fatalError("out of memory");
          624  +      }
   622    625       }
   623    626       if( in!=stdin ) fclose(in);
   624    627       lastPct = -1;
   625    628   
   626    629       /* Skip initial lines of the input file that begin with "#" */
   627    630       for(i=0; i<nIn; i=iNext+1){
   628    631         if( zIn[i]!='#' ) break;
................................................................................
   666    669             int pct = (10*iNext)/nIn;
   667    670             if( pct!=lastPct ){
   668    671               if( lastPct<0 ) printf("%s:", zPrompt);
   669    672               printf(" %d%%", pct*10);
   670    673               lastPct = pct;
   671    674             }
   672    675           }
          676  +      }else if( nInFile>1 ){
          677  +        printf("%s\n", zPrompt);
   673    678         }
   674    679         fflush(stdout);
   675    680   
   676    681         /* Run the next test case.  Run it multiple times in --oom mode
   677    682         */
   678    683         if( oomFlag ){
   679    684           oomCnt = g.iOomCntdown = 1;
................................................................................
   799    804       }
   800    805       if( !verboseFlag && multiTest && !quietFlag && !oomFlag ) printf("\n");
   801    806     }
   802    807   
   803    808     /* Report total number of tests run
   804    809     */
   805    810     if( nTest>1 && !quietFlag ){
   806         -    printf("%s: 0 errors out of %d tests\nSQLite %s %s\n",
   807         -           g.zArgv0, nTest, sqlite3_libversion(), sqlite3_sourceid());
          811  +    sqlite3_int64 iElapse = timeOfDay() - iBegin;
          812  +    printf("%s: 0 errors out of %d tests in %d.%03d seconds\nSQLite %s %s\n",
          813  +           g.zArgv0, nTest, (int)(iElapse/1000), (int)(iElapse%1000),
          814  +           sqlite3_libversion(), sqlite3_sourceid());
   808    815     }
   809    816   
   810    817     /* Write the unique test cases if the --unique-cases flag was used
   811    818     */
   812    819     if( zDataOut ){
   813    820       int n = 0;
   814    821       FILE *out = fopen(zDataOut, "wb");