in src/main/core-impl/java/com/mysql/cj/log/BaseMetricsHolder.java [184:293]
public void reportMetrics(Log log) {
StringBuilder logMessage = new StringBuilder(256);
logMessage.append("** Performance Metrics Report **\n");
logMessage.append("\nLongest reported query: " + this.longestQueryTimeMs + " ms");
logMessage.append("\nShortest reported query: " + this.shortestQueryTimeMs + " ms");
logMessage.append("\nAverage query execution time: " + this.totalQueryTimeMs / this.numberOfQueriesIssued + " ms");
logMessage.append("\nNumber of statements executed: " + this.numberOfQueriesIssued);
logMessage.append("\nNumber of result sets created: " + this.numberOfResultSetsCreated);
logMessage.append("\nNumber of statements prepared: " + this.numberOfPrepares);
logMessage.append("\nNumber of prepared statement executions: " + this.numberOfPreparedExecutes);
if (this.perfMetricsHistBreakpoints != null) {
logMessage.append("\n\n\tTiming Histogram:\n");
int maxNumPoints = 20;
int highestCount = Integer.MIN_VALUE;
for (int i = 0; i < HISTOGRAM_BUCKETS; i++) {
if (this.perfMetricsHistCounts[i] > highestCount) {
highestCount = this.perfMetricsHistCounts[i];
}
}
if (highestCount == 0) {
highestCount = 1; // avoid DIV/0
}
for (int i = 0; i < HISTOGRAM_BUCKETS - 1; i++) {
if (i == 0) {
logMessage.append("\n\tless than " + this.perfMetricsHistBreakpoints[i + 1] + " ms: \t" + this.perfMetricsHistCounts[i]);
} else {
logMessage.append("\n\tbetween " + this.perfMetricsHistBreakpoints[i] + " and " + this.perfMetricsHistBreakpoints[i + 1] + " ms: \t"
+ this.perfMetricsHistCounts[i]);
}
logMessage.append("\t");
int numPointsToGraph = (int) (maxNumPoints * ((double) this.perfMetricsHistCounts[i] / highestCount));
for (int j = 0; j < numPointsToGraph; j++) {
logMessage.append("*");
}
if (this.longestQueryTimeMs < this.perfMetricsHistCounts[i + 1]) {
break;
}
}
if (this.perfMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 2] < this.longestQueryTimeMs) {
logMessage.append("\n\tbetween ");
logMessage.append(this.perfMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 2]);
logMessage.append(" and ");
logMessage.append(this.perfMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 1]);
logMessage.append(" ms: \t");
logMessage.append(this.perfMetricsHistCounts[HISTOGRAM_BUCKETS - 1]);
}
}
if (this.numTablesMetricsHistBreakpoints != null) {
logMessage.append("\n\n\tTable Join Histogram:\n");
int maxNumPoints = 20;
int highestCount = Integer.MIN_VALUE;
for (int i = 0; i < HISTOGRAM_BUCKETS; i++) {
if (this.numTablesMetricsHistCounts[i] > highestCount) {
highestCount = this.numTablesMetricsHistCounts[i];
}
}
if (highestCount == 0) {
highestCount = 1; // avoid DIV/0
}
for (int i = 0; i < HISTOGRAM_BUCKETS - 1; i++) {
if (i == 0) {
logMessage.append("\n\t" + this.numTablesMetricsHistBreakpoints[i + 1] + " tables or less: \t\t" + this.numTablesMetricsHistCounts[i]);
} else {
logMessage.append("\n\tbetween " + this.numTablesMetricsHistBreakpoints[i] + " and " + this.numTablesMetricsHistBreakpoints[i + 1]
+ " tables: \t" + this.numTablesMetricsHistCounts[i]);
}
logMessage.append("\t");
int numPointsToGraph = (int) (maxNumPoints * ((double) this.numTablesMetricsHistCounts[i] / highestCount));
for (int j = 0; j < numPointsToGraph; j++) {
logMessage.append("*");
}
if (this.maximumNumberTablesAccessed < this.numTablesMetricsHistBreakpoints[i + 1]) {
break;
}
}
if (this.numTablesMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 2] < this.maximumNumberTablesAccessed) {
logMessage.append("\n\tbetween ");
logMessage.append(this.numTablesMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 2]);
logMessage.append(" and ");
logMessage.append(this.numTablesMetricsHistBreakpoints[HISTOGRAM_BUCKETS - 1]);
logMessage.append(" tables: ");
logMessage.append(this.numTablesMetricsHistCounts[HISTOGRAM_BUCKETS - 1]);
}
}
log.logInfo(logMessage);
//this.metricsLastReportedMs = System.currentTimeMillis();
}