var data_sizes = [ {id: "10000000", name: "10 mln."}, {id: "100000000", name: "100 mln."}, {id: "1000000000", name: "1 bn."} ]; var systems = []; var systems_full = []; var system_kinds = []; var systems_uniq = {}; for (r in results) { if (systems_uniq[results[r].system]) continue; systems_uniq[results[r].system] = 1; systems.push(results[r].system); systems_full.push(results[r].system_full); system_kinds.push(results[r].kind); } var runs = ["first (cold cache)", "second", "third"]; var current_runs = ['1', '2']; try { var state = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); current_data_size = state[0]; current_systems = state[1]; current_runs = state[2]; } catch (e) { } if (!current_systems.length) { current_systems = systems; } function update_hash() { window.location.hash = JSON.stringify([current_data_size, current_systems, current_runs]); } function generate_selectors(elem) { var html = '

Compare

'; var available_results = results; if (current_data_size) { available_results = results.filter(function (run) { return run.data_size == current_data_size; }); } var available_systems_for_current_data_size = available_results.map(function (run) { return run.system; }); for (var i = 0; i < systems.length; i++) { var selected = current_systems.indexOf(systems[i]) != -1; var available = available_systems_for_current_data_size.indexOf(systems[i]) != -1; var button_class = 'btn-outline-dark'; if (system_kinds[i] == 'cloud' || system_kinds[i] == 'vps') { button_class = 'btn-outline-primary'; } else if (system_kinds[i] == 'desktop' || system_kinds[i] == 'laptop') { button_class = 'btn-outline-secondary'; }; html += '

Dataset size

'; for (var i = 0; i < data_sizes.length; i++) { html += ''; } } html += '

Run

'; for (var i = 0; i < runs.length; i++) { html += ''; } html += '
'; elem.html(html); $('button').focus(function() { $('[data-toggle="tooltip"]').tooltip('hide'); }); $('#systems_selector button:not(.disabled)').click(function (event) { event.preventDefault(); var target = $(event.target || event.srcElement); if (target.hasClass("active") && current_systems.length == 1) { return; } target.toggleClass("active"); current_systems = $.map($('#systems_selector button'), function (elem) { return $(elem).hasClass("active") ? $(elem).html() : null }).filter(function (x) { return x; }); update_hash(); generate_selectors(elem); generate_comparison_table(); generate_diagram(); }); if (current_data_size) { $('#data_size_selector button').click(function (event) { event.preventDefault(); var target = $(event.target || event.srcElement); current_data_size = target.attr("data-size-id"); update_hash(); generate_selectors(elem); generate_comparison_table(); generate_diagram(); }); } $('#runs_selector button').click(function (event) { event.preventDefault(); var target = $(event.target || event.srcElement); if (target.hasClass("active") && current_runs.length == 1) { return; } target.toggleClass("active"); current_runs = $.map($('#runs_selector button'), function (elem) { return $(elem).hasClass("active") ? $(elem).attr("data-run-id") : null }).filter(function (x) { return x; }); update_hash(); generate_selectors(elem); generate_comparison_table(); generate_diagram(); }); } function format_number_cell(value, ratio) { var html = ""; var redness = (ratio - 1) / ratio; var blackness = ratio < 10 ? 0 : ((ratio - 10) / ratio / 2); var color = !value ? "#FFF" : ratio == 1 ? ("rgba(0, 255, 0, 1)") : ("rgba(" + ~~(255 * (1 - blackness)) + ", 0, 0, " + redness + ")"); html += ""; html += value ? (ratio == 1 ? "" : ("×" + ratio.toFixed(2))) + " (" + value.toFixed(3) + " s.)" : "—"; html += ""; return html; } /* Ratio of execution time to best execution time: * system index -> run index -> query index -> ratio. */ var ratios = []; function generate_comparison_table() { ratios = []; var filtered_results = results; if (current_data_size) { filtered_results = filtered_results.filter(function (x) { return x.data_size == current_data_size; }); } filtered_results = filtered_results.filter(function (x) { return current_systems.indexOf(x.system) != -1; }); var html = ""; html += ""; html += ""; html += ""; html += ""; for (var j = 0; j < filtered_results.length; j++) { html += ""; for (var i = 0; i < queries.length; i++) { html += ""; html += ""; html += ""; // Max and min execution time per system, for each of three runs var minimums = [0, 0, 0], maximums = [0, 0, 0]; for (var j = 0; j < filtered_results.length; j++) { for (var current_run_idx = 0; current_run_idx < current_runs.length; current_run_idx++) { var k = current_runs[current_run_idx]; var value = filtered_results[j].result[i][k]; if (value && (!minimums[k] || value < minimums[k])) { minimums[k] = value; // Ignore below 10ms if (minimums[k] < 0.01) { minimums[k] = 0.01; } } if (value > maximums[k]) { maximums[k] = value; } } } for (var j = 0; j < filtered_results.length; j++) { if (!ratios[j]) { ratios[j] = []; } for (var current_run_idx = 0; current_run_idx < current_runs.length; current_run_idx++) { var k = current_runs[current_run_idx]; var value = filtered_results[j].result[i][k]; var ratio = value / minimums[k]; ratios[j][k] = ratios[j][k] || []; if (ratio && ratio <= 1) { ratio = 1; } ratios[j][k].push(ratio); html += format_number_cell(value, ratio); } } html += ""; } if (current_systems.length) { html += ""; html += ""; html += ""; for (var j = 0; j < filtered_results.length; j++) { for (var k = 0; k < current_runs.length; k++) { html += ""; } } html += ""; html += ""; for (var j = 0; j < filtered_results.length; j++) { html += ""; } html += ""; } html += "
Query"; } html += "
" + queries[i].query + "
Geometric mean of ratios
"; $('#comparison_table').html(html); for (var i = 0; i < queries.length; i++) { $('#query_checkbox' + i).click(function () { calculate_totals(); generate_diagram(); }); } $('#query_checkbox_toggler').click(function () { for (var i = 0; i < queries.length; i++) { var item = $('#query_checkbox' + i); item.prop("checked", !item.prop("checked")); } }); calculate_totals(); } function calculate_totals() { if (!current_systems.length) return; var filtered_results = results; if (current_data_size) { filtered_results = filtered_results.filter(function (x) { return x.data_size == current_data_size; }); } filtered_results = filtered_results.filter(function (x) { return current_systems.indexOf(x.system) != -1; }); var total_ratios = []; for (var j = 0; j < filtered_results.length; j++) { for (var current_run_idx = 0; current_run_idx < current_runs.length; current_run_idx++) { var k = current_runs[current_run_idx]; var current_ratios = ratios[j][k].filter( function (x, i) { return x && $("#query_checkbox" + i).is(':checked'); } ); var ratio = Math.pow( current_ratios.reduce( function (acc, cur) { return acc * cur; }, 1), 1 / current_ratios.length); total_ratios[j] = total_ratios[j] || 1; total_ratios[j] *= ratio; $("#totals" + j + "_" + k).attr("data-ratio", ratio).html("x" + ratio.toFixed(2)); } } for (var j = 0; j < filtered_results.length; j++) { var total_ratio = Math.pow(total_ratios[j], 1 / current_runs.length); $("#absolute_totals" + j).attr("data-ratio", total_ratio).html("x" + total_ratio.toFixed(2)); } } function generate_diagram() { var html = ""; var filtered_results = results; if (current_data_size) { filtered_results = filtered_results.filter(function (x) { return x.data_size == current_data_size && current_systems.indexOf(x.system) != -1; }); } filtered_results = filtered_results.filter(function (x) { return current_systems.indexOf(x.system) != -1; }); var max_ratio = 1; var min_ratio = 0; var max_total_ratio = 1; var min_total_ratio = 0; for (var j = 0; j < filtered_results.length; j++) { for (var current_run_idx = 0; current_run_idx < current_runs.length; current_run_idx++) { var k = current_runs[current_run_idx]; var ratio = +$("#totals" + j + "_" + k).attr("data-ratio"); if (ratio > max_ratio) { max_ratio = ratio; } if (!min_ratio || ratio < min_ratio) { min_ratio = ratio; } } var total_ratio = +$("#absolute_totals" + j).attr("data-ratio"); if (total_ratio > max_total_ratio) { max_total_ratio = total_ratio; } if (!min_total_ratio || total_ratio < min_total_ratio) { min_total_ratio = total_ratio; } } html += ""; var table_rows = []; for (var j = 0; j < filtered_results.length; j++) { var total_ratio = +$("#absolute_totals" + j).attr("data-ratio"); var table_row = ""; table_row += ""; table_row += ""; table_row += ""; table_row += ""; table_row += ""; table_rows.push({ data: table_row, value: total_ratio / min_total_ratio }); } table_rows.sort(function(a, b) { return a.value - b.value; }); for (var j = 0; j < table_rows.length; j++) { html += table_rows[j].data; } html += "
" : "") + ""; for (var current_run_idx = 0; current_run_idx < current_runs.length; current_run_idx++) { var k = current_runs[current_run_idx]; var ratio = +$("#totals" + j + "_" + k).attr("data-ratio"); var percents = (ratio * 100 / max_ratio).toFixed(2); if (!ratio) { ratio = +$("#absolute_totals" + j).attr("data-ratio"); percents = (ratio * 100 / max_total_ratio).toFixed(2); } table_row += '
 
'; } table_row += "
" + (total_ratio / min_total_ratio).toFixed(2) + "
"; $('#diagram').html(html); $('[data-toggle="tooltip"]').tooltip({ trigger: 'hover', delay: { "show": 300, "hide": 100 } }); } generate_selectors($('#selectors')); generate_comparison_table(); generate_diagram();