/ Check-in [b3c61051]
Login

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

Overview
Comment:Add options to speedtest1.c and speed-check.sh for testing performance of floating-point computatations.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | mistake
Files: files | file ages | folders
SHA3-256: b3c6105181d22c8a53f5bf662e3d182bba962ee8afd1ad972ebd10094b20fc17
User & Date: drh 2017-12-26 14:12:49
Context
2017-12-26
14:30
Add options to speedtest1.c and speed-check.sh for testing performance of floating-point computatations. check-in: ebfea872 user: dan tags: trunk
14:12
Add options to speedtest1.c and speed-check.sh for testing performance of floating-point computatations. Closed-Leaf check-in: b3c61051 user: drh tags: mistake
14:11
Fix crashes that could occur if SQL NULL values were passed to the built-in FTS5 snippet function. Edit: breaks amalgamation builds. check-in: 553a3ad3 user: dan tags: mistake
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/speedtest1.c.

    28     28     "  --serialized        Set serialized threading mode\n"
    29     29     "  --singlethread      Set single-threaded mode - disables all mutexing\n"
    30     30     "  --sqlonly           No-op.  Only show the SQL that would have been run.\n"
    31     31     "  --shrink-memory     Invoke sqlite3_db_release_memory() frequently.\n"
    32     32     "  --size N            Relative test size.  Default=100\n"
    33     33     "  --stats             Show statistics at the end\n"
    34     34     "  --temp N            N from 0 to 9.  0: no temp table. 9: all temp tables\n"
    35         -  "  --testset T         Run test-set T (main, cte, rtree, orm, debug)\n"
           35  +  "  --testset T         Run test-set T (main, cte, rtree, orm, fp, debug)\n"
    36     36     "  --trace             Turn on SQL tracing\n"
    37     37     "  --threads N         Use up to N threads for sorting\n"
    38     38     "  --utf16be           Set text encoding to UTF-16BE\n"
    39     39     "  --utf16le           Set text encoding to UTF-16LE\n"
    40     40     "  --verify            Run additional verification steps.\n"
    41     41     "  --without-rowid     Use WITHOUT ROWID where appropriate\n"
    42     42   ;
................................................................................
  1116   1116       "SELECT count(x), avg(x) FROM (\n"
  1117   1117       "  SELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1\n"
  1118   1118       ");",
  1119   1119       nElem, nElem
  1120   1120     );
  1121   1121     speedtest1_run();
  1122   1122     speedtest1_end_test();
         1123  +}
  1123   1124   
         1125  +/*
         1126  +** Compute a pseudo-random floating point ascii number.
         1127  +*/
         1128  +void speedtest1_random_ascii_fp(char *zFP){
         1129  +  int x = speedtest1_random();
         1130  +  int y = speedtest1_random();
         1131  +  int z;
         1132  +  z = y%10;
         1133  +  if( z<0 ) z = -z;
         1134  +  y /= 10;
         1135  +  sqlite3_snprintf(100,zFP,"%d.%de%d",y,z,x%200);
         1136  +}
         1137  +
         1138  +/*
         1139  +** A testset for floating-point numbers.
         1140  +*/
         1141  +void testset_fp(void){
         1142  +  int n;
         1143  +  int i;
         1144  +  char zFP1[100];
         1145  +  char zFP2[100];
         1146  +  
         1147  +  n = g.szTest*5000;
         1148  +  speedtest1_begin_test(100, "Fill a table with %d FP values", n*2);
         1149  +  speedtest1_exec("BEGIN");
         1150  +  speedtest1_exec("CREATE%s TABLE t1(a REAL %s, b REAL %s);",
         1151  +                  isTemp(1), g.zNN, g.zNN);
         1152  +  speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2); -- %d times", n);
         1153  +  for(i=1; i<=n; i++){
         1154  +    speedtest1_random_ascii_fp(zFP1);
         1155  +    speedtest1_random_ascii_fp(zFP2);
         1156  +    sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
         1157  +    sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
         1158  +    speedtest1_run();
         1159  +  }
         1160  +  speedtest1_exec("COMMIT");
         1161  +  speedtest1_end_test();
         1162  +
         1163  +  n = g.szTest/25 + 2;
         1164  +  speedtest1_begin_test(110, "%d range queries", n);
         1165  +  speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
         1166  +  for(i=1; i<=n; i++){
         1167  +    speedtest1_random_ascii_fp(zFP1);
         1168  +    speedtest1_random_ascii_fp(zFP2);
         1169  +    sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
         1170  +    sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
         1171  +    speedtest1_run();
         1172  +  }
         1173  +  speedtest1_end_test();
         1174  +
         1175  +  speedtest1_begin_test(120, "CREATE INDEX three times");
         1176  +  speedtest1_exec("BEGIN;");
         1177  +  speedtest1_exec("CREATE INDEX t1a ON t1(a);");
         1178  +  speedtest1_exec("CREATE INDEX t1b ON t1(b);");
         1179  +  speedtest1_exec("CREATE INDEX t1ab ON t1(a,b);");
         1180  +  speedtest1_exec("COMMIT;");
         1181  +  speedtest1_end_test();
         1182  +
         1183  +  n = g.szTest/3 + 2;
         1184  +  speedtest1_begin_test(130, "%d indexed range queries", n);
         1185  +  speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
         1186  +  for(i=1; i<=n; i++){
         1187  +    speedtest1_random_ascii_fp(zFP1);
         1188  +    speedtest1_random_ascii_fp(zFP2);
         1189  +    sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
         1190  +    sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
         1191  +    speedtest1_run();
         1192  +  }
         1193  +  speedtest1_end_test();
  1124   1194   }
  1125   1195   
  1126   1196   #ifdef SQLITE_ENABLE_RTREE
  1127   1197   /* Generate two numbers between 1 and mx.  The first number is less than
  1128   1198   ** the second.  Usually the numbers are near each other but can sometimes
  1129   1199   ** be far apart.
  1130   1200   */
................................................................................
  1869   1939       testset_main();
  1870   1940     }else if( strcmp(zTSet,"debug1")==0 ){
  1871   1941       testset_debug1();
  1872   1942     }else if( strcmp(zTSet,"orm")==0 ){
  1873   1943       testset_orm();
  1874   1944     }else if( strcmp(zTSet,"cte")==0 ){
  1875   1945       testset_cte();
         1946  +  }else if( strcmp(zTSet,"fp")==0 ){
         1947  +    testset_fp();
  1876   1948     }else if( strcmp(zTSet,"rtree")==0 ){
  1877   1949   #ifdef SQLITE_ENABLE_RTREE
  1878   1950       testset_rtree(6, 147);
  1879   1951   #else
  1880   1952       fatal_error("compile with -DSQLITE_ENABLE_RTREE to enable "
  1881   1953                   "the R-Tree tests\n");
  1882   1954   #endif
  1883   1955     }else{
  1884         -    fatal_error("unknown testset: \"%s\"\nChoices: main debug1 cte rtree\n",
         1956  +    fatal_error("unknown testset: \"%s\"\nChoices: main debug1 cte rtree fp\n",
  1885   1957                    zTSet);
  1886   1958     }
  1887   1959     speedtest1_final();
  1888   1960   
  1889   1961     if( showStats ){
  1890   1962       sqlite3_exec(g.db, "PRAGMA compile_options", xCompileOptions, 0, 0);
  1891   1963     }

Changes to tool/speed-check.sh.

   113    113       --rtree)
   114    114           SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset rtree"
   115    115           CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_RTREE"
   116    116           ;;
   117    117       --orm)
   118    118           SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
   119    119           ;;
          120  +    --cte)
          121  +        SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
          122  +        ;;
          123  +    --fp)
          124  +        SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
          125  +        ;;
   120    126       -*)
   121    127           CC_OPTS="$CC_OPTS $1"
   122    128           ;;
   123    129       *)
   124    130   	BASELINE=$1
   125    131           ;;
   126    132     esac