]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Update fp-speed-1.c and fp-speed-2.c to include its own timers, so that it
authordrh <>
Fri, 27 Mar 2026 14:19:01 +0000 (14:19 +0000)
committerdrh <>
Fri, 27 Mar 2026 14:19:01 +0000 (14:19 +0000)
works on platforms that lack the "time" command.

FossilOrigin-Name: 9b083070de2d782fe1db62652af8f3cd48abe16b55b974f3927b738e3d914887

manifest
manifest.uuid
test/fp-speed-1.c
test/fp-speed-2.c

index 45fb8844fd615d508f0d1f42a92a447f8b51a74d..576ae58ea1238265fa95dd9490402503bd4a205f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\sfp-speed-2.c\sperformance\stest\sprogram.
-D 2026-03-27T14:03:41.832
+C Update\sfp-speed-1.c\sand\sfp-speed-2.c\sto\sinclude\sits\sown\stimers,\sso\sthat\sit\nworks\son\splatforms\sthat\slack\sthe\s"time"\scommand.
+D 2026-03-27T14:19:01.594
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -1126,8 +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 a3a59b8822857918ed3aa90f195884c00f542efa8afd7529188550f948cb0995
-F test/fp-speed-2.c 2f3b208ce8a6324a0fd74321a9040f46f0e09fc4d0dd20e721517e12704dde31
+F test/fp-speed-1.c d5a2e3ab88b190fdbc7835b33ae78ac15967f6012907cb28ed3f40b76e21786e
+F test/fp-speed-2.c af6b1fbd368c3981566b14e3c1932badf31c65624456e10dd36433ef3be6b8fb
 F test/fpconv1.test 63f352682fa65601a326563ad633086df6ab194e6ed5e7366786f38a525a7fd7
 F test/fptest01.sql 210562ad8d5a7895f26273dd3be56561a41bcb51d78a28a337af0f1ceaa3bb8d
 F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c
@@ -2196,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 cd472d7c85f3fda54bba5166eae72b5f9b86861c4a1160583e8ee902ba992255
-R f34e0fa460503e1caaba2303ab84843f
+P b788256f1980531e7abb15c5fbcdd40ae166f091aea28f449c0407105ddf1aa4
+R f42aecab7436b20b96c2b346a6e94f0e
 U drh
-Z 1b7a44c07f55210ac3d9d7d1d33633e4
+Z b1baed1b56fbdbc43bde1513944e1825
 # Remove this line to create a well-formed Fossil manifest.
index e55f842ff4a3a28b0d526f82caad945cd045aad9..dfa6cc19babc11a54be02c378c492fb089928a39 100644 (file)
@@ -1 +1 @@
-b788256f1980531e7abb15c5fbcdd40ae166f091aea28f449c0407105ddf1aa4
+9b083070de2d782fe1db62652af8f3cd48abe16b55b974f3927b738e3d914887
index 79c0721327c1a951f4c3b5dba2bb846ce4e97040..2cd0af90500790b9874227f210cf734738c11240 100644 (file)
 **
 ** To run the test:
 **
-**    time ./a.out 0 10000000     <-- standard library
-**    time ./a.out 1 10000000     <-- SQLite
+**    ./a.out 0 10000000     <-- standard library
+**    ./a.out 1 10000000     <-- SQLite
 */
+#include "sqlite3.h"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _WIN32
+# include <windows.h>
+#else
+# include <sys/time.h>
+#endif
+
 static double aVal[] = {
   -1.0163830486285643089e+063,
   +0.0049243807391586981e-019,
@@ -120,14 +129,44 @@ static double aVal[] = {
 };
 #define NN (sizeof(aVal)/sizeof(aVal[0]))
 
-#include "sqlite3.h"
-#include <stdio.h>
-#include <stdlib.h>
+/* Return the current wall-clock time in microseconds since the
+** Unix epoch (1970-01-01T00:00:00Z)
+*/
+static sqlite3_int64 timeOfDay(void){
+#if defined(_WIN64) && _WIN32_WINNT >= _WIN32_WINNT_WIN8
+  sqlite3_uint64 t;
+  FILETIME tm;
+  GetSystemTimePreciseAsFileTime(&tm);
+  t =  ((sqlite3_uint64)tm.dwHighDateTime<<32) |
+          (sqlite3_uint64)tm.dwLowDateTime;
+  t += 116444736000000000LL;
+  t /= 10;
+  return t;
+#elif defined(_WIN32)
+  static sqlite3_vfs *clockVfs = 0;
+  sqlite3_int64 t;
+  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+  if( clockVfs==0 ) return 0;  /* Never actually happens */
+  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
+    clockVfs->xCurrentTimeInt64(clockVfs, &t);
+  }else{
+    double r;
+    clockVfs->xCurrentTime(clockVfs, &r);
+    t = (sqlite3_int64)(r*86400000.0);
+  }
+  return t*1000;
+#else
+  struct timeval sNow;
+  (void)gettimeofday(&sNow,0);
+  return ((sqlite3_int64)sNow.tv_sec)*1000000 + sNow.tv_usec;
+#endif
+}
 
 int main(int argc, char **argv){
   int i;
   int cnt;
   int fg;
+  sqlite3_int64 tm;
   char zBuf[1000];
 
   if( argc!=3 ){
@@ -137,6 +176,7 @@ int main(int argc, char **argv){
   cnt = atoi(argv[2]);
   fg = atoi(argv[1]);
 
+  tm = timeOfDay();
   switch( fg % 3 ){
     case 0: {
       printf("Doing %d calls to C-lib sprintf()\n", cnt);
@@ -153,5 +193,7 @@ int main(int argc, char **argv){
       break;
     }
   }
+  tm = timeOfDay() - tm;
+  printf("Elapse time: %lld.%06lld seconds\n", tm/1000000, tm%1000000);
   return 0;
 }
index f5116f628c560b9cd83271d69dfd437279fa183a..e3c8cd7878d9e3f2a0b549218f7d56345617d99b 100644 (file)
 **
 ** 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
+**    ./a.out 0 10000000     <-- standard library
+**    ./a.out 1 10000000     <-- SQLite
+**    ./a.out 2 10000000     <-- test program overhead
 */
+#include "sqlite3.h"
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#ifdef _WIN32
+# include <windows.h>
+#else
+# include <sys/time.h>
+#endif
 
 static const char *aVal[] = {
   "-1.01638304862856430",
@@ -125,15 +131,45 @@ static const char *aVal[] = {
 };
 #define NN (sizeof(aVal)/sizeof(aVal[0]))
 
+/* Return the current wall-clock time in microseconds since the
+** Unix epoch (1970-01-01T00:00:00Z)
+*/
+static sqlite3_int64 timeOfDay(void){
+#if defined(_WIN64) && _WIN32_WINNT >= _WIN32_WINNT_WIN8
+  sqlite3_uint64 t;
+  FILETIME tm;
+  GetSystemTimePreciseAsFileTime(&tm);
+  t =  ((sqlite3_uint64)tm.dwHighDateTime<<32) |
+          (sqlite3_uint64)tm.dwLowDateTime;
+  t += 116444736000000000LL;
+  t /= 10;
+  return t;
+#elif defined(_WIN32)
+  static sqlite3_vfs *clockVfs = 0;
+  sqlite3_int64 t;
+  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+  if( clockVfs==0 ) return 0;  /* Never actually happens */
+  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
+    clockVfs->xCurrentTimeInt64(clockVfs, &t);
+  }else{
+    double r;
+    clockVfs->xCurrentTime(clockVfs, &r);
+    t = (sqlite3_int64)(r*86400000.0);
+  }
+  return t*1000;
+#else
+  struct timeval sNow;
+  (void)gettimeofday(&sNow,0);
+  return ((sqlite3_int64)sNow.tv_sec)*1000000 + sNow.tv_usec;
+#endif
+}
 
-#include "sqlite3.h"
-#include <stdio.h>
-#include <stdlib.h>
 
 int main(int argc, char **argv){
   int i;
   int cnt;
   int fg;
+  sqlite3_int64 tm;
   double arSum[401];
   char z[1000];
 
@@ -144,6 +180,7 @@ int main(int argc, char **argv){
   cnt = atoi(argv[2]);
   fg = atoi(argv[1]);
 
+  tm = timeOfDay();
   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;
@@ -193,6 +230,8 @@ int main(int argc, char **argv){
     }
   }
   for(i=1; i<=400; i++) arSum[0] += arSum[i];
-  printf("Grand total: %g\n", arSum[0]);
+  printf("Checksum: %g\n", arSum[0]);
+  tm = timeOfDay() - tm;
+  printf("Elapse time: %lld.%06lld seconds\n", tm/1000000, tm%1000000);
   return 0;
 }