Add the "number_of_cores" TCL command to the testfixture.

FossilOrigin-Name: 16ee5a7b5d02cad51a35d5675fcc5bb50a62d1f243bde107fc89fed44ffd6a43
This commit is contained in:
drh 2023-02-24 13:25:49 +00:00
parent 8ac60da70e
commit 1fa0f27e81
3 changed files with 49 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Slightly\sfaster\sand\smore\sprecise\sfloating-point\sto\sdecimal\sconversion.\nSee\s[forum:/forumpost/d1387c3979c7f557|forum\sthread\sd1387c3979c7f557]\sfor\ndiscussion.
D 2023-02-24T11:54:40.435
C Add\sthe\s"number_of_cores"\sTCL\scommand\sto\sthe\stestfixture.
D 2023-02-24T13:25:49.251
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -631,7 +631,7 @@ F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a3
F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c 8522a04fb9c84faa1d80354430ae0ee9349727a3a4b32e3cfe39b9be8324cabd
F src/test1.c 29ab8aca939818a61bf791e4ff5d45df6da30940c0980dcf502562b925de4e05
F src/test1.c e23623dc569d2d18d1201d624ec279e9a96f0d9e83bf0620c8680d62b35d4ee7
F src/test2.c 827446e259a3b7ab949da1542953edda7b5117982576d3e6f1c24a0dd20a5cef
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664
@ -2046,9 +2046,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P de6c5c6bb49a0beca793cdc0462da2c17bb05f3292e08dd815be29b45b59a8fb f32055e8110a2eac6c9e26d1d1e620f0668bcb475d49d309dc549cea05e1e582
R d1a241fa3d7686eec8ef50c8409ad626
T +closed f32055e8110a2eac6c9e26d1d1e620f0668bcb475d49d309dc549cea05e1e582
P 6dea6f4738fc7d003183e94f08bd95181f23e165a966882c0bdc64708a05a607
R ec9d2605f4b41b74f37dda061eea41aa
U drh
Z bef52b6fcdf6ca2cb08784252d92c2c0
Z 7c7b73264f13980fd1dcea1f8e67ede6
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
6dea6f4738fc7d003183e94f08bd95181f23e165a966882c0bdc64708a05a607
16ee5a7b5d02cad51a35d5675fcc5bb50a62d1f243bde107fc89fed44ffd6a43

View File

@ -16,6 +16,13 @@
#include "sqliteInt.h"
#if SQLITE_OS_WIN
# include "os_win.h"
# include <windows.h>
#else
# include <unistd.h>
# if defined(__APPLE__)
# include <sys/param.h>
# include <sys/sysctl.h>
# endif
#endif
#include "vdbeInt.h"
@ -8639,6 +8646,40 @@ static int SQLITE_TCLAPI test_autovacuum_pages(
return TCL_OK;
}
/*
** Usage: number_of_cores
**
** Return a guess at the number of available cores available on the
** processor on which this process is running.
*/
static int SQLITE_TCLAPI guess_number_of_cores(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
unsigned int nCore = 1;
#if SQLITE_OS_WIN
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
nCore = (unsigned int)sysinfo.dwNumberOfProcessors;
#elif defined(__APPLE__)
int nm[2];
size_t len = 4;
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
sysctl(nm, 2, &nCore, &len, NULL, 0);
if( nCore<1 ){
nm[1] = HW_NCPU;
sysctl(nm, 2, &nCore, &len, NULL, 0);
}
#else
nCore = sysconf(_SC_NPROCESSORS_ONLN);
#endif
if( nCore<=0 ) nCore = 1;
Tcl_SetObjResult(interp, Tcl_NewIntObj((int)nCore));
return SQLITE_OK;
}
/*
** Register commands with the TCL interpreter.
@ -8939,6 +8980,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "test_write_db", test_write_db, 0 },
{ "sqlite3_register_cksumvfs", test_register_cksumvfs, 0 },
{ "sqlite3_unregister_cksumvfs", test_unregister_cksumvfs, 0 },
{ "number_of_cores", guess_number_of_cores, 0 },
};
static int bitmask_size = sizeof(Bitmask)*8;
static int longdouble_size = sizeof(LONGDOUBLE_TYPE);