From: drh <> Date: Fri, 27 Mar 2026 14:03:41 +0000 (+0000) Subject: Add the fp-speed-2.c performance test program. X-Git-Tag: major-release~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4570aeb7bc4713b6564fbd9eb4ba6b11d9be7a09;p=thirdparty%2Fsqlite.git Add the fp-speed-2.c performance test program. FossilOrigin-Name: b788256f1980531e7abb15c5fbcdd40ae166f091aea28f449c0407105ddf1aa4 --- diff --git a/manifest b/manifest index 0a15ae3ac3..45fb8844fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scomment\sshowing\sreserved\sfile-control\snumbers\sto\ssqlite3.h -D 2026-03-27T11:46:11.333 +C Add\sthe\sfp-speed-2.c\sperformance\stest\sprogram. +D 2026-03-27T14:03:41.832 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -1126,7 +1126,8 @@ F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749 F test/fordelete.test ba98f14446b310f9c9d935b97ec748753d0144a28b356ba30d1f4f6958fdde5c F test/fork-test.c 9ac2e6423a1d38df3d6be0e8ac15608b545de21e2b19d9d876254c5931b63edb F test/format4.test eeae341953db8b6bda7f549044797c3278a6cc345d11ada81471671b654f8ef4 -F test/fp-speed-1.c b37de94eba034e1703668816225f54510ec60fb0685406608cc707afe6b8234d +F test/fp-speed-1.c a3a59b8822857918ed3aa90f195884c00f542efa8afd7529188550f948cb0995 +F test/fp-speed-2.c 2f3b208ce8a6324a0fd74321a9040f46f0e09fc4d0dd20e721517e12704dde31 F test/fpconv1.test 63f352682fa65601a326563ad633086df6ab194e6ed5e7366786f38a525a7fd7 F test/fptest01.sql 210562ad8d5a7895f26273dd3be56561a41bcb51d78a28a337af0f1ceaa3bb8d F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c @@ -2195,8 +2196,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P c5af6a10245b6b847d30002806c1577b020c36ab27f7b1cf202ade136aa4779c -R 51ff65a6bd1b538cf25dd22d8d1484ee +P cd472d7c85f3fda54bba5166eae72b5f9b86861c4a1160583e8ee902ba992255 +R f34e0fa460503e1caaba2303ab84843f U drh -Z d9594447f664fc3f5df800bf2243aaf0 +Z 1b7a44c07f55210ac3d9d7d1d33633e4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0f229184a6..e55f842ff4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd472d7c85f3fda54bba5166eae72b5f9b86861c4a1160583e8ee902ba992255 +b788256f1980531e7abb15c5fbcdd40ae166f091aea28f449c0407105ddf1aa4 diff --git a/test/fp-speed-1.c b/test/fp-speed-1.c index cb4e0409c3..79c0721327 100644 --- a/test/fp-speed-1.c +++ b/test/fp-speed-1.c @@ -2,6 +2,9 @@ ** Performance testing of floating-point binary-to-decimal conversion for ** SQLite versus the standard library. ** +** This module compares library sprintf() against SQLite's sqlite3_snprintf(). +** To go the other direction (decimal-to-binary) see fp-speed-2.c. +** ** To compile: ** ** make sqlite3.c diff --git a/test/fp-speed-2.c b/test/fp-speed-2.c new file mode 100644 index 0000000000..f5116f628c --- /dev/null +++ b/test/fp-speed-2.c @@ -0,0 +1,198 @@ +/* +** Performance testing of floating-point decimal-to-binary conversion for +** SQLite versus the standard library. +** +** This module compares library atof() against SQLite's sqlite3AtoF(). +** To go the other direction (binary-to-decimal) see fp-speed-1.c. +** +** To compile: +** +** make sqlite3.c +** gcc -Os -c sqlite3.c +** gcc -I. -Os test/fp-speed-2.c sqlite3.o -ldl -lm -lpthread +** +** To run the test: +** +** time ./a.out 0 10000000 <-- standard library +** time ./a.out 1 10000000 <-- SQLite +** time ./a.out 2 10000000 <-- test program overhead +*/ +#include +#include +#include + +static const char *aVal[] = { + "-1.01638304862856430", + "+0.00492438073915869", + "+7.38187324073439948", + "+7.06785952192257171", + "+9.28072663198500256", + "+5.88710508619333946", + "-2.29980236212596628", + "-1.59035819249108474", + "+2.43134418168449782", + "-3.82909873289453990", + "+1.87879140627440013", + "+0.72706535604871466", + "+0.06395776979131836", + "+5.22923388793158619", + "+6.37476826728722313", + "+8.69723395383291069", + "-9.50744860515976919", + "-8.64802578453687530", + "-3.56575957757974703", + "-7.83231061797317613", + "+7.78138752741208003", + "-1.87397189283601965", + "+8.68981459155933572", + "+6.05667663598778378", + "+4.17033792171481606", + "+2.12838712887466515", + "-6.83952360838918106", + "-6.21142997639395291", + "-2.07535257426146373", + "+5.87274598039442902", + "+8.58889910620021018", + "+6.86244610313559176", + "-3.30539867566709051", + "-4.35968431527634449", + "+0.08341395201040996", + "-8.85819865489042224", + "-3.66220954287276982", + "-6.69658522970250632", + "+1.82041693474064884", + "+6.52345080386490003", + "+1.59230060182190114", + "+1.73625552916563894", + "+7.28754319768547858", + "+1.28358801059589267", + "+8.05162533203208194", + "+6.63246333993811454", + "-1.71265000702800620", + "+1.69957383415837123", + "+7.60487669237386637", + "+0.61591172354494550", + "+5.75448943554159432", + "+8.29702285926905818", + "-6.55319253601630674", + "+5.83213346061870300", + "+5.65571665095718917", + "+0.33227897084384087", + "-7.12106487766986866", + "-9.67212625267063433", + "-3.45839165713773950", + "+4.78960943232147507", + "-9.69260280400041378", + "+7.06838482753813854", + "-5.29701141821629619", + "-4.42870212009053932", + "+0.07288911557328087", + "-9.18554620258794474", + "+3.72941262341310077", + "+2.68574218827927192", + "-4.70706073336246853", + "+7.21758207682793342", + "-8.36784125342611634", + "+2.21748443042418221", + "+0.19498245886068610", + "-9.73340529556720719", + "-9.77938877669369998", + "-5.15611645874169315", + "-7.50489935777651747", + "+7.35560765686877845", + "-5.06816285755335998", + "+1.52097056420277478", + "-7.59897825350482960", + "+1.36541372033897758", + "-1.64417205546513720", + "-4.90424331961411259", + "-7.70636119616491307", + "+0.16994274609307662", + "+8.33743178495722168", + "-5.23553304804695800", + "-3.85100459421941479", + "-6.35136225443263398", + "+2.38693034844544289", + "+3.83527158716203602", + "-3.12631204931368879", + "-5.57947970025564908", + "-8.81098744795956043", + "-4.37273601202032169", + "-3.11099511896685399", + "-9.48418780317042682", + "-3.73984516683044072", + "+4.89840420089159599", +}; +#define NN (sizeof(aVal)/sizeof(aVal[0])) + + +#include "sqlite3.h" +#include +#include + +int main(int argc, char **argv){ + int i; + int cnt; + int fg; + double arSum[401]; + char z[1000]; + + if( argc!=3 ){ + fprintf(stderr, "Usage: %s FLAG COUNT\n", argv[0]); + return 1; + } + cnt = atoi(argv[2]); + fg = atoi(argv[1]); + + switch( fg % 4 ){ + case 0: printf("Doing %d calls to C-lib atof()\n", cnt); break; + case 1: printf("Doing %d calls to sqlite3AtoF()\n", cnt); break; + case 2: printf("Test overhead only for %d cases\n", cnt); break; + case 3: printf("Print the first %d cases\n", cnt); break; + } + memset(arSum, 0, sizeof(arSum)); + for(i=0; i