| Report " + rep + (rep == 0 ? " (reference)":"") + " | ";
- // median
+ // min
+ table_output += "" + time_label(report.sorted_data[0]) + " | ";
+ // percentiles (median, p99, p99.9)
table_output += "" + time_label(report.sorted_data[Math.floor(report.sorted_data.length/2)]) + " | ";
+ table_output += "" + time_label(quantile(report.sorted_data, 0.99)) + " | ";
+ table_output += "" + time_label(quantile(report.sorted_data, 0.999)) + " | ";
// max
table_output += "" + time_label(report.sorted_data[report.sorted_data.length-1]) + " | ";
+ // sum
+ table_output += "" + time_label(report.sorted_data.reduce((a, b) => a + b, 0)) + " | ";
let frames_better = 0;
let frames_diff = 0;
for (const f in report.time_data)
diff --git a/source/tools/profiler2/utilities.js b/source/tools/profiler2/utilities.js
index d5f72c437f..9b2a4f5632 100644
--- a/source/tools/profiler2/utilities.js
+++ b/source/tools/profiler2/utilities.js
@@ -159,3 +159,16 @@ function set_tooltip_handlers(canvas)
$('#tooltip').css('visibility', 'hidden');
});
}
+
+/**
+ * Get the specified quantile of a sorted array.
+ */
+function quantile(arr, q)
+{
+ const position = (arr.length - 1) * q;
+ const base = Math.floor(position);
+ const remainder = position - base;
+ if (arr[base + 1] !== undefined)
+ return arr[base] + remainder * (arr[base + 1] - arr[base]);
+ return arr[base];
+}