Enhance the ".stats" dot-command in the CLI to use sqlite3_status64() instead

of sqlite3_status().

FossilOrigin-Name: 118f5c0564fef70cbd06fc0d9dbb2baec162cc39
This commit is contained in:
drh 2017-03-10 14:36:10 +00:00
parent f157d10f9f
commit a2df53bd61
3 changed files with 52 additions and 53 deletions

View File

@ -1,5 +1,5 @@
C Improvements\sto\s".selftest\s--init".\s\sTests\sare\snumber\sin\sincrements\sof\s10\nstarting\swith\s100.\s\sThe\stests\sare\sgenerated\sinside\sa\sSAVEPOINT.\s\sErrors\sare\nreported\sduring\stest\sgeneration.\s\sTests\scan\sbe\sappended\sto\sexisting\stests.\nAdd\sa\stest\scase\sto\sverify\sthe\sschema.
D 2017-03-10T01:05:38.013
C Enhance\sthe\s".stats"\sdot-command\sin\sthe\sCLI\sto\suse\ssqlite3_status64()\sinstead\nof\ssqlite3_status().
D 2017-03-10T14:36:10.584
F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc a89ea37ab5928026001569f056973b9059492fe2
@ -400,7 +400,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 3e518b962d932a997fae373366880fc028c75706
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c d12f3539f80db38b09015561b569e0eb1c4b6c5f
F src/shell.c 0435e7ea18865e8bd435c9fbe018e1a8431964a7
F src/shell.c 4d9be7f0622365029a1f2e0f9628b8e363700ff5
F src/sqlite.h.in 4d0c08f8640c586564a7032b259c5f69bf397850
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
@ -1563,7 +1563,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P f4fcd46f08ba59d2a3e772cad98383129f648386
R 2a153e04b79acc8e7981c04d4b205835
P b044b152aac2ec606750940ea816ad4a4aef8eb6
R da300103282ee8980f2e41cc2466def0
U drh
Z c20519a5ebf6e7586b129dc9c77c4f4b
Z 6dbad136ee05d7b8bc7f34310ddbaf47

View File

@ -1 +1 @@
b044b152aac2ec606750940ea816ad4a4aef8eb6
118f5c0564fef70cbd06fc0d9dbb2baec162cc39

View File

@ -2259,6 +2259,31 @@ static void displayLinuxIoStats(FILE *out){
}
#endif
/*
** Display a single line of status using 64-bit values.
*/
static void displayStatLine(
ShellState *p, /* The shell context */
char *zLabel, /* Label for this one line */
char *zFormat, /* Format for the result */
int iStatusCtrl, /* Which status to display */
int bReset /* True to reset the stats */
){
sqlite3_int64 iCur = -1;
sqlite3_int64 iHiwtr = -1;
int i, nPercent;
char zLine[200];
sqlite3_status64(iStatusCtrl, &iCur, &iHiwtr, bReset);
for(i=0, nPercent=0; zFormat[i]; i++){
if( zFormat[i]=='%' ) nPercent++;
}
if( nPercent>1 ){
sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iCur, iHiwtr);
}else{
sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iHiwtr);
}
raw_printf(p->out, "%-36s %s\n", zLabel, zLine);
}
/*
** Display memory stats.
@ -2272,57 +2297,31 @@ static int display_stats(
int iHiwtr;
if( pArg && pArg->out ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out,
"Memory Used: %d (max %d) bytes\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n",
iCur, iHiwtr);
displayStatLine(pArg, "Memory Used:",
"%lld (max %lld) bytes", SQLITE_STATUS_MEMORY_USED, bReset);
displayStatLine(pArg, "Number of Outstanding Allocations:",
"%lld (max %lld)", SQLITE_STATUS_MALLOC_COUNT, bReset);
if( pArg->shellFlgs & SHFLG_Pagecache ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out,
"Number of Pcache Pages Used: %d (max %d) pages\n",
iCur, iHiwtr);
displayStatLine(pArg, "Number of Pcache Pages Used:",
"%lld (max %lld) pages", SQLITE_STATUS_PAGECACHE_USED, bReset);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out,
"Number of Pcache Overflow Bytes: %d (max %d) bytes\n",
iCur, iHiwtr);
displayStatLine(pArg, "Number of Pcache Overflow Bytes:",
"%lld (max %lld) bytes", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset);
if( pArg->shellFlgs & SHFLG_Scratch ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out,
"Number of Scratch Allocations Used: %d (max %d)\n",
iCur, iHiwtr);
displayStatLine(pArg, "Number of Scratch Allocations Used:",
"%lld (max %lld)", SQLITE_STATUS_SCRATCH_USED, bReset);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out,
"Number of Scratch Overflow Bytes: %d (max %d) bytes\n",
iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Largest Allocation: %d bytes\n",
iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Largest Pcache Allocation: %d bytes\n",
iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Largest Scratch Allocation: %d bytes\n",
iHiwtr);
displayStatLine(pArg, "Number of Scratch Overflow Bytes:",
"%lld (max %lld) bytes", SQLITE_STATUS_SCRATCH_OVERFLOW, bReset);
displayStatLine(pArg, "Largest Allocation:",
"%lld bytes", SQLITE_STATUS_MALLOC_SIZE, bReset);
displayStatLine(pArg, "Largest Pcache Allocation:",
"%lld bytes", SQLITE_STATUS_PAGECACHE_SIZE, bReset);
displayStatLine(pArg, "Largest Scratch Allocation:",
"%lld bytes", SQLITE_STATUS_SCRATCH_SIZE, bReset);
#ifdef YYTRACKMAXSTACKDEPTH
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
raw_printf(pArg->out, "Deepest Parser Stack: %d (max %d)\n",
iCur, iHiwtr);
displayStatLine(pArg, "Deepest Parser Stack:",
"%lld (max %lld)", SQLITE_STATUS_PARSER_STACK, bReset);
#endif
}