aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <Dan Kennedy>2024-06-24 14:53:14 +0000
committerdan <Dan Kennedy>2024-06-24 14:53:14 +0000
commit1d8cde9d56d153767e98595c4b015221864ef0e7 (patch)
treeed93c95522db33f0f05dfdd0c1429035b2ab6184 /src
parent51b3b402c49c2535749c7e790fb52a017e3f5674 (diff)
downloadsqlite-1d8cde9d56d153767e98595c4b015221864ef0e7.tar.gz
sqlite-1d8cde9d56d153767e98595c4b015221864ef0e7.zip
Enhance the output of ".scanstats vm" to include the absolute number of ticks for each VM instruction, instead of just the percentage of the total.
FossilOrigin-Name: 1535828335d2b0eccebae952ed2bc70cc0cd893bd4b079d26b80deff9b5f752b
Diffstat (limited to 'src')
-rw-r--r--src/shell.c.in10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shell.c.in b/src/shell.c.in
index 58475dd6d..a5bfab589 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -2420,7 +2420,7 @@ static int shell_callback(
case MODE_Explain: {
static const int aExplainWidth[] = {4, 13, 4, 4, 4, 13, 2, 13};
static const int aExplainMap[] = {0, 1, 2, 3, 4, 5, 6, 7 };
- static const int aScanExpWidth[] = {4, 6, 6, 13, 4, 4, 4, 13, 2, 13};
+ static const int aScanExpWidth[] = {4, 15, 6, 13, 4, 4, 4, 13, 2, 13};
static const int aScanExpMap[] = {0, 9, 8, 1, 2, 3, 4, 5, 6, 7 };
const int *aWidth = aExplainWidth;
@@ -3430,7 +3430,13 @@ static void display_scanstats(
if( pArg->scanstatsOn==3 ){
const char *zSql =
" SELECT addr, opcode, p1, p2, p3, p4, p5, comment, nexec,"
- " round(ncycle*100.0 / (sum(ncycle) OVER ()), 2)||'%' AS cycles"
+ " format('% 6s (%.2f%%)',"
+ " CASE WHEN ncycle<100_000 THEN ncycle || ' '"
+ " WHEN ncycle<100_000_000 THEN (ncycle/1_000) || 'K'"
+ " WHEN ncycle<100_000_000_000 THEN (ncycle/1_000_000) || 'M'"
+ " ELSE (ncycle/1000_000_000) || 'G' END,"
+ " ncycle*100.0/(sum(ncycle) OVER ())"
+ " ) AS cycles"
" FROM bytecode(?)";
int rc = SQLITE_OK;