diff --git a/source/tools/profiler2/profiler2.js b/source/tools/profiler2/profiler2.js index c124b5ecff..cb2b192d3d 100644 --- a/source/tools/profiler2/profiler2.js +++ b/source/tools/profiler2/profiler2.js @@ -307,19 +307,26 @@ function compare_reports() for (const rep in g_reports) { - const raw_data = get_history_data(rep, g_main_thread, g_active_elements[0]).time_by_frame; + const raw_data_t = get_history_data(rep, g_main_thread, g_active_elements[0]); + const raw_data = raw_data_t.time_by_frame; reports_data.push({ "time_data": raw_data.slice(0, frames_nb), "sorted_data": raw_data.slice(0, frames_nb).sort((a, b) => a-b) }); } - let table_output = ""; + let table_output = "
Profiler VariableMedianMaximum% better framestime difference per frame
"; for (const rep in reports_data) { const report = reports_data[rep]; table_output += ""; - // median + // min + table_output += ""; + // percentiles (median, p99, p99.9) table_output += ""; + table_output += ""; + table_output += ""; // max table_output += ""; + // sum + table_output += ""; 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]; +}
Profiler VariableMinimumMedianp99p99.9MaximumSumbetter framestime difference per frame
Report " + rep + (rep == 0 ? " (reference)":"") + "" + time_label(report.sorted_data[0]) + "" + time_label(report.sorted_data[Math.floor(report.sorted_data.length/2)]) + "" + time_label(quantile(report.sorted_data, 0.99)) + "" + time_label(quantile(report.sorted_data, 0.999)) + "" + time_label(report.sorted_data[report.sorted_data.length-1]) + "" + time_label(report.sorted_data.reduce((a, b) => a + b, 0)) + "