From cc9798bb677bca589a2ceeccd7d171fb438b5b8d Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Wed, 27 Nov 2024 12:58:08 +0100 Subject: [PATCH] feat: add commas to large numbers to make them easier to read Signed-off-by: Andres Taylor --- go/summarize/markdown.go | 8 ++++---- .../bigger_slow_log_avg-rows-examined.md | 20 +++++++++---------- go/testdata/bigger_slow_log_avg-time.md | 20 +++++++++---------- .../bigger_slow_log_total-rows-examined.md | 20 +++++++++---------- go/testdata/bigger_slow_log_total-time.md | 20 +++++++++---------- go/testdata/bigger_slow_log_usage-count.md | 20 +++++++++---------- go/testdata/transactions-summary.md | 3 ++- 7 files changed, 56 insertions(+), 55 deletions(-) diff --git a/go/summarize/markdown.go b/go/summarize/markdown.go index afaef2c..94b80fe 100644 --- a/go/summarize/markdown.go +++ b/go/summarize/markdown.go @@ -60,10 +60,10 @@ func renderHotQueries(md *markdown.MarkDown, queries []keys.QueryAnalysisResult, avgQueryTime := query.QueryTime / float64(query.UsageCount) rows = append(rows, []string{ queryID, - strconv.Itoa(query.UsageCount), + humanize.Comma(int64(query.UsageCount)), fmt.Sprintf("%.2f", query.QueryTime), fmt.Sprintf("%.2f", avgQueryTime), - strconv.Itoa(query.RowsExamined), + humanize.Comma(int64(query.RowsExamined)), }) } @@ -112,8 +112,8 @@ func renderTableOverview(md *markdown.MarkDown, tableSummaries []*TableSummary, for _, summary := range tableSummaries { thisRow := []string{ summary.Table, - strconv.Itoa(summary.ReadQueryCount), - strconv.Itoa(summary.WriteQueryCount), + humanize.Comma(int64(summary.ReadQueryCount)), + humanize.Comma(int64(summary.WriteQueryCount)), } if includeRowCount { thisRow = append(thisRow, humanize.Comma(int64(summary.RowCount))) diff --git a/go/testdata/bigger_slow_log_avg-rows-examined.md b/go/testdata/bigger_slow_log_avg-rows-examined.md index 968e154..fb42f1f 100644 --- a/go/testdata/bigger_slow_log_avg-rows-examined.md +++ b/go/testdata/bigger_slow_log_avg-rows-examined.md @@ -6,16 +6,16 @@ ## Top Queries |Query ID|Usage Count|Total Query Time (ms)|Avg Query Time (ms)|Total Rows Examined| |---|---|---|---|---| -|Q1|2|0.40|0.20|20000| -|Q2|3|0.61|0.20|30000| -|Q3|1|0.22|0.22|8000| -|Q4|2|0.37|0.19|16000| -|Q5|2|0.37|0.19|16000| -|Q6|2|0.49|0.25|16000| -|Q7|2|0.31|0.16|15000| -|Q8|1|0.20|0.20|6500| -|Q9|3|0.58|0.19|17000| -|Q10|2|0.34|0.17|8500| +|Q1|2|0.40|0.20|20,000| +|Q2|3|0.61|0.20|30,000| +|Q3|1|0.22|0.22|8,000| +|Q4|2|0.37|0.19|16,000| +|Q5|2|0.37|0.19|16,000| +|Q6|2|0.49|0.25|16,000| +|Q7|2|0.31|0.16|15,000| +|Q8|1|0.20|0.20|6,500| +|Q9|3|0.58|0.19|17,000| +|Q10|2|0.34|0.17|8,500| ### Query Details #### Q1 diff --git a/go/testdata/bigger_slow_log_avg-time.md b/go/testdata/bigger_slow_log_avg-time.md index 4d70414..3e68c7e 100644 --- a/go/testdata/bigger_slow_log_avg-time.md +++ b/go/testdata/bigger_slow_log_avg-time.md @@ -6,16 +6,16 @@ ## Top Queries |Query ID|Usage Count|Total Query Time (ms)|Avg Query Time (ms)|Total Rows Examined| |---|---|---|---|---| -|Q1|2|0.49|0.25|16000| -|Q2|1|0.22|0.22|8000| -|Q3|3|0.61|0.20|30000| -|Q4|2|0.40|0.20|20000| -|Q5|1|0.20|0.20|6500| -|Q6|3|0.58|0.19|17000| -|Q7|2|0.37|0.19|16000| -|Q8|2|0.37|0.19|16000| -|Q9|2|0.34|0.17|8500| -|Q10|2|0.33|0.17|6000| +|Q1|2|0.49|0.25|16,000| +|Q2|1|0.22|0.22|8,000| +|Q3|3|0.61|0.20|30,000| +|Q4|2|0.40|0.20|20,000| +|Q5|1|0.20|0.20|6,500| +|Q6|3|0.58|0.19|17,000| +|Q7|2|0.37|0.19|16,000| +|Q8|2|0.37|0.19|16,000| +|Q9|2|0.34|0.17|8,500| +|Q10|2|0.33|0.17|6,000| ### Query Details #### Q1 diff --git a/go/testdata/bigger_slow_log_total-rows-examined.md b/go/testdata/bigger_slow_log_total-rows-examined.md index ce5ddd1..c8bb5a7 100644 --- a/go/testdata/bigger_slow_log_total-rows-examined.md +++ b/go/testdata/bigger_slow_log_total-rows-examined.md @@ -6,16 +6,16 @@ ## Top Queries |Query ID|Usage Count|Total Query Time (ms)|Avg Query Time (ms)|Total Rows Examined| |---|---|---|---|---| -|Q1|3|0.61|0.20|30000| -|Q2|2|0.40|0.20|20000| -|Q3|3|0.58|0.19|17000| -|Q4|2|0.37|0.19|16000| -|Q5|2|0.37|0.19|16000| -|Q6|2|0.49|0.25|16000| -|Q7|2|0.31|0.16|15000| -|Q8|2|0.34|0.17|8500| -|Q9|1|0.22|0.22|8000| -|Q10|1|0.20|0.20|6500| +|Q1|3|0.61|0.20|30,000| +|Q2|2|0.40|0.20|20,000| +|Q3|3|0.58|0.19|17,000| +|Q4|2|0.37|0.19|16,000| +|Q5|2|0.37|0.19|16,000| +|Q6|2|0.49|0.25|16,000| +|Q7|2|0.31|0.16|15,000| +|Q8|2|0.34|0.17|8,500| +|Q9|1|0.22|0.22|8,000| +|Q10|1|0.20|0.20|6,500| ### Query Details #### Q1 diff --git a/go/testdata/bigger_slow_log_total-time.md b/go/testdata/bigger_slow_log_total-time.md index ca8b4c4..64651c7 100644 --- a/go/testdata/bigger_slow_log_total-time.md +++ b/go/testdata/bigger_slow_log_total-time.md @@ -6,16 +6,16 @@ ## Top Queries |Query ID|Usage Count|Total Query Time (ms)|Avg Query Time (ms)|Total Rows Examined| |---|---|---|---|---| -|Q1|3|0.61|0.20|30000| -|Q2|3|0.58|0.19|17000| -|Q3|2|0.49|0.25|16000| -|Q4|2|0.40|0.20|20000| -|Q5|2|0.37|0.19|16000| -|Q6|2|0.37|0.19|16000| -|Q7|2|0.34|0.17|8500| -|Q8|2|0.33|0.17|6000| -|Q9|2|0.31|0.16|15000| -|Q10|1|0.22|0.22|8000| +|Q1|3|0.61|0.20|30,000| +|Q2|3|0.58|0.19|17,000| +|Q3|2|0.49|0.25|16,000| +|Q4|2|0.40|0.20|20,000| +|Q5|2|0.37|0.19|16,000| +|Q6|2|0.37|0.19|16,000| +|Q7|2|0.34|0.17|8,500| +|Q8|2|0.33|0.17|6,000| +|Q9|2|0.31|0.16|15,000| +|Q10|1|0.22|0.22|8,000| ### Query Details #### Q1 diff --git a/go/testdata/bigger_slow_log_usage-count.md b/go/testdata/bigger_slow_log_usage-count.md index 015a38a..ed0f032 100644 --- a/go/testdata/bigger_slow_log_usage-count.md +++ b/go/testdata/bigger_slow_log_usage-count.md @@ -6,16 +6,16 @@ ## Top Queries |Query ID|Usage Count|Total Query Time (ms)|Avg Query Time (ms)|Total Rows Examined| |---|---|---|---|---| -|Q1|3|0.58|0.19|17000| -|Q2|3|0.61|0.20|30000| -|Q3|2|0.21|0.11|3000| -|Q4|2|0.37|0.19|16000| -|Q5|2|0.31|0.16|15000| -|Q6|2|0.40|0.20|20000| -|Q7|2|0.34|0.17|8500| -|Q8|2|0.33|0.17|6000| -|Q9|2|0.37|0.19|16000| -|Q10|2|0.49|0.25|16000| +|Q1|3|0.58|0.19|17,000| +|Q2|3|0.61|0.20|30,000| +|Q3|2|0.21|0.11|3,000| +|Q4|2|0.37|0.19|16,000| +|Q5|2|0.31|0.16|15,000| +|Q6|2|0.40|0.20|20,000| +|Q7|2|0.34|0.17|8,500| +|Q8|2|0.33|0.17|6,000| +|Q9|2|0.37|0.19|16,000| +|Q10|2|0.49|0.25|16,000| ### Query Details #### Q1 diff --git a/go/testdata/transactions-summary.md b/go/testdata/transactions-summary.md index 6acb2fa..2853115 100644 --- a/go/testdata/transactions-summary.md +++ b/go/testdata/transactions-summary.md @@ -5,7 +5,8 @@ ## Transaction Patterns -Pattern 1 (Observed 2 times) +### Pattern 1 (Observed 2 times) + Tables Involved: tblA, tblB ### Query Patterns