-C Reduce\sthe\scompiled\ssize\sof\sthe\squote()\sSQL\sfunction.
-D 2026-03-28T13:59:34.275
+C Enhancements\sto\sthe\sfp-speed-N.c\sprograms,\ssuggested\sby\sAndreas\sKupries.
+D 2026-03-28T14:17:53.130
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F test/fordelete.test ba98f14446b310f9c9d935b97ec748753d0144a28b356ba30d1f4f6958fdde5c
F test/fork-test.c 9ac2e6423a1d38df3d6be0e8ac15608b545de21e2b19d9d876254c5931b63edb
F test/format4.test eeae341953db8b6bda7f549044797c3278a6cc345d11ada81471671b654f8ef4
-F test/fp-speed-1.c 0e2c6d117ba08979392db480042d44a2ebb16447f831676b5388911b357134a7
-F test/fp-speed-2.c 26638811adc2f98618569bb90b2ed1c409c36ba79b543e6961d923d2a177931c
+F test/fp-speed-1.c 34a2fe8dc30d0b24bb3e7c16efca0a30452287da6caff7dde86eef882db155a4
+F test/fp-speed-2.c 8afff93f00ac034a48e49182b971404480a495c7be4b8a4310e2075cbbb801d5
F test/fpconv1.test 63f352682fa65601a326563ad633086df6ab194e6ed5e7366786f38a525a7fd7
F test/fptest01.sql 3d84f10bb1cc220b59207354c887d720289903adeb9972a29d6bfcb3fec0df95
F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 75e8703664ae94244284819d9021877a5fc33a268fb86f3e70de20875a766d80
-R 53c0174f1ec620322f6cab99495c3f2a
+P 9ea980a35628f7d0741ab6c65840ab9dab8abb576c6c60109147336452f9637a
+R c4218918ce643c1d84226f485b2be1d8
U drh
-Z 4c1395d7057fba4fd91b56b6ca2cdace
+Z 734c45e6bb399241b8bc1b6c0f71f745
# Remove this line to create a well-formed Fossil manifest.
return 1;
}
- tm1 = timeOfDay();
printf("C-library sprintf(\"%s\"): ", zFmt);
fflush(stdout);
+ tm1 = timeOfDay();
for(i=0; i<cnt; i++){
sprintf(zBuf, zFmt, aVal[i%NN]);
}
tm1 = timeOfDay() - tm1;
printf("%6.1f ns/call, %9.6f sec total\n", tm1*1.0e+3/(double)cnt,tm1*1.0e-6);
- tm2 = timeOfDay();
+
printf("sqlite3_snprintf(\"%s\"): ", zFmt);
+ tm2 = timeOfDay();
for(i=0; i<cnt; i++){
sqlite3_snprintf(sizeof(zBuf), zBuf, zFmt, aVal[i%NN]);
}
tm2 = timeOfDay() - tm2;
printf("%6.1f ns/call, %9.6f sec total\n", tm2*1.0e+3/(double)cnt,tm2*1.0e-6);
+
if( tm1 < tm2 ){
printf("sprintf() is about %g times faster than sqlite3_snprintf()\n",
(double)tm2/(double)tm1);
** To run the test:
**
** ./a.out 10000000
+**
+** Notes:
+**
+** * A first loop is run to measure the testing overhead. This
+** overhead is then subtracted from the times of subsequent loops
+** so that the estimates are for the calls to atof() or
+** sqlite3AtoF() only.
*/
#include "sqlite3.h"
#include <string.h>
#endif
}
+/*
+** Generate text of the i-th test floating-point literal.
+*/
+static int fpLiteral(int i, char *z){
+ int e, ex, len, ix;
+ ex = i%401;
+ e = ex - 200;
+ len = (i/401)%16 + 4;
+ ix = (i/(401*16))%NN;
+ memcpy(z, aVal[ix], len);
+ z[len++] = 'e';
+ if( e<0 ){
+ z[len++] = '-';
+ e = -e;
+ }else{
+ z[len++] = '+';
+ }
+ z[len++] = e/100 + '0';
+ z[len++] = (e/10)%10 + '0';
+ z[len++] = e%10 + '0';
+ z[len] = 0;
+ return ex;
+}
int main(int argc, char **argv){
int i;
return 1;
}
- for(fg=0; fg<=2; fg++){
- tm[fg] = timeOfDay();
- switch( fg ){
- case 0: printf("C-lib atof(): "); break;
- case 1: printf("sqlite3AtoF(): "); break;
- case 2: printf("Test overhead: "); break;
- }
- fflush(stdout);
- memset(arSum, 0, sizeof(arSum));
- for(i=0; i<cnt; i++){
- int e, ex, len, ix;
- ex = i%401;
- e = ex - 200;
- len = (i/401)%16 + 4;
- ix = (i/(401*16))%NN;
- memcpy(z, aVal[ix], len);
- z[len++] = 'e';
- if( e<0 ){
- z[len++] = '-';
- e = -e;
- }else{
- z[len++] = '+';
- }
- z[len++] = e/100 + '0';
- z[len++] = (e/10)%10 + '0';
- z[len++] = e%10 + '0';
- z[len] = 0;
- switch( fg ){
- case 0: {
- arSum[ex] += atof(z);
- break;
- }
- case 1: {
- double r = 0.0;
- sqlite3_test_control(SQLITE_TESTCTRL_ATOF, z, &r);
- arSum[ex] += r;
- break;
- }
- case 2: {
- double r = (double)i;
- arSum[ex] += r;
- break;
- }
- break;
- }
- }
- for(i=1; i<=400; i++) arSum[0] += arSum[i];
- tm[fg] = timeOfDay() - tm[fg];
- printf("%6.1f ns/test, %9.6f sec total", tm[fg]*1e3/cnt, tm[fg]*1e-6);
- if( fg<2 ){
- printf(", cksum: %g\n", arSum[0]);
- }else{
- printf("\n");
- }
+ printf("test-overhead: ");
+ fflush(stdout);
+ memset(arSum, 0, sizeof(arSum));
+ tm[2] = timeOfDay();
+ for(i=0; i<cnt; i++){
+ double r = (double)i;
+ int ex = fpLiteral(i,z);
+ arSum[ex] += r;
+ }
+ tm[2] = timeOfDay() - tm[2];
+ for(i=1; i<=400; i++) arSum[0] += arSum[i];
+ printf("%6.1f ns/test, %9.6f sec total\n", tm[2]*1e3/cnt, tm[2]*1e-6);
+
+ printf("C-lib atof(): ");
+ fflush(stdout);
+ memset(arSum, 0, sizeof(arSum));
+ tm[0] = timeOfDay();
+ for(i=0; i<cnt; i++){
+ int ex = fpLiteral(i,z);
+ arSum[ex] += atof(z);
}
- tm[0] -= tm[2];
- tm[1] -= tm[2];
+ tm[0] = timeOfDay() - tm[0] - tm[2];
+ for(i=1; i<=400; i++) arSum[0] += arSum[i];
+ printf("%6.1f ns/test, %9.6f sec net", tm[0]*1e3/cnt, tm[0]*1e-6);
+ printf(", cksum: %g\n", arSum[0]);
+
+ printf("sqlite3AtoF(): ");
+ fflush(stdout);
+ memset(arSum, 0, sizeof(arSum));
+ tm[1] = timeOfDay();
+ for(i=0; i<cnt; i++){
+ double r = 0.0;
+ int ex = fpLiteral(i,z);
+ sqlite3_test_control(SQLITE_TESTCTRL_ATOF, z, &r);
+ arSum[ex] += r;
+ }
+ tm[1] = timeOfDay() - tm[1] - tm[2];
+ for(i=1; i<=400; i++) arSum[0] += arSum[i];
+ printf("%6.1f ns/test, %9.6f sec net", tm[1]*1e3/cnt, tm[1]*1e-6);
+ printf(", cksum: %g\n", arSum[0]);
+
if( tm[0] < tm[1] ){
printf("atof() is about %g times faster than sqlite3AtoF()\n",
(double)tm[1]/(double)tm[0]);