** Display memory stats. */
| 12738 | ** Display memory stats. |
| 12739 | */ |
| 12740 | static int display_stats( |
| 12741 | sqlite3 *db, /* Database to query */ |
| 12742 | ShellState *pArg, /* Pointer to ShellState */ |
| 12743 | int bReset /* True to reset the stats */ |
| 12744 | ){ |
| 12745 | int iCur; |
| 12746 | int iHiwtr; |
| 12747 | FILE *out; |
| 12748 | if( pArg==0 || pArg->out==0 ) return 0; |
| 12749 | out = pArg->out; |
| 12750 | |
| 12751 | if( pArg->pStmt && pArg->statsOn==2 ){ |
| 12752 | int nCol, i, x; |
| 12753 | sqlite3_stmt *pStmt = pArg->pStmt; |
| 12754 | char z[100]; |
| 12755 | nCol = sqlite3_column_count(pStmt); |
| 12756 | raw_printf(out, "%-36s %d\n", "Number of output columns:", nCol); |
| 12757 | for(i=0; i<nCol; i++){ |
| 12758 | sqlite3_snprintf(sizeof(z),z,"Column %d %nname:", i, &x); |
| 12759 | utf8_printf(out, "%-36s %s\n", z, sqlite3_column_name(pStmt,i)); |
| 12760 | #ifndef SQLITE_OMIT_DECLTYPE |
| 12761 | sqlite3_snprintf(30, z+x, "declared type:"); |
| 12762 | utf8_printf(out, "%-36s %s\n", z, sqlite3_column_decltype(pStmt, i)); |
| 12763 | #endif |
| 12764 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 12765 | sqlite3_snprintf(30, z+x, "database name:"); |
| 12766 | utf8_printf(out, "%-36s %s\n", z, sqlite3_column_database_name(pStmt,i)); |
| 12767 | sqlite3_snprintf(30, z+x, "table name:"); |
| 12768 | utf8_printf(out, "%-36s %s\n", z, sqlite3_column_table_name(pStmt,i)); |
| 12769 | sqlite3_snprintf(30, z+x, "origin name:"); |
| 12770 | utf8_printf(out, "%-36s %s\n", z, sqlite3_column_origin_name(pStmt,i)); |
| 12771 | #endif |
| 12772 | } |
| 12773 | } |
| 12774 | |
| 12775 | if( pArg->statsOn==3 ){ |
| 12776 | if( pArg->pStmt ){ |
| 12777 | iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset); |
| 12778 | raw_printf(pArg->out, "VM-steps: %d\n", iCur); |
| 12779 | } |
| 12780 | return 0; |
| 12781 | } |
| 12782 | |
| 12783 | displayStatLine(pArg, "Memory Used:", |
| 12784 | "%lld (max %lld) bytes", SQLITE_STATUS_MEMORY_USED, bReset); |
| 12785 | displayStatLine(pArg, "Number of Outstanding Allocations:", |
| 12786 | "%lld (max %lld)", SQLITE_STATUS_MALLOC_COUNT, bReset); |
| 12787 | if( pArg->shellFlgs & SHFLG_Pagecache ){ |
| 12788 | displayStatLine(pArg, "Number of Pcache Pages Used:", |
| 12789 | "%lld (max %lld) pages", SQLITE_STATUS_PAGECACHE_USED, bReset); |
| 12790 | } |
| 12791 | displayStatLine(pArg, "Number of Pcache Overflow Bytes:", |
| 12792 | "%lld (max %lld) bytes", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset); |
| 12793 | displayStatLine(pArg, "Largest Allocation:", |
| 12794 | "%lld bytes", SQLITE_STATUS_MALLOC_SIZE, bReset); |
| 12795 | displayStatLine(pArg, "Largest Pcache Allocation:", |
| 12796 | "%lld bytes", SQLITE_STATUS_PAGECACHE_SIZE, bReset); |
| 12797 | #ifdef YYTRACKMAXSTACKDEPTH |
no test coverage detected