test: fix wrong sorting in benchmarks summary

This commit is contained in:
Jędrzej Boczar 2020-02-20 09:19:02 +01:00
parent a27841199b
commit 247722d97e
1 changed files with 5 additions and 7 deletions

View File

@ -84,7 +84,7 @@
// sort human-readable values assuming format "123 Kb", only first letter of unit is used // sort human-readable values assuming format "123 Kb", only first letter of unit is used
jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function(data) { jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function(data) {
var matches = data.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)/i); var matches = data.match(/^(\d+(?:\.\d+)?)\s*(\S+)/i);
var multipliers = { var multipliers = {
k: Math.pow(2, 10), k: Math.pow(2, 10),
m: Math.pow(2, 20), m: Math.pow(2, 20),
@ -92,14 +92,12 @@
t: Math.pow(2, 40), t: Math.pow(2, 40),
}; };
console.log(matches);
if (matches) { if (matches) {
var float = parseFloat(matches[1]); var float = parseFloat(matches[1]);
var prefix = matches[2].toLowerCase()[0]; var prefix = matches[2].toLowerCase()[0];
var multiplier = multipliers[prefix]; var multiplier = multipliers[prefix];
if (multiplier) { if (multiplier) {
float = float * multiplier; float = float * multiplier;
console.log(matches, float, multiplier);
} }
return float; return float;
} else { } else {
@ -113,10 +111,10 @@
for (var id of table_ids) { for (var id of table_ids) {
// add human readable class to all bandwidth columns // add human readable class to all bandwidth columns
var columns = $('#' + id + ' > thead > tr > th').filter(function(index) { var columns = $('#' + id + ' > thead > tr > th').filter(function(index) {
return $(this).text().toLowerCase().includes('bandwidth'); var name = $(this).text().toLowerCase();
return name.includes('bandwidth') || name.includes('latency') || name.includes('efficiency');
}); });
console.log(columns) columns.addClass('data-with-unit-human-readable');
columns.addClass('human-readable-data');
// construct data table // construct data table
table = $('#' + id); table = $('#' + id);
@ -124,7 +122,7 @@
paging: false, paging: false,
fixedHeader: true, fixedHeader: true,
columnDefs: [ columnDefs: [
{ type: 'file-size', targets: [ 'human-readable-data' ] }, { type: 'file-size', targets: [ 'data-with-unit-human-readable' ] },
{ className: 'dt-body-right', targets: [ '_all' ] }, { className: 'dt-body-right', targets: [ '_all' ] },
{ className: 'dt-head-center', targets: [ '_all' ] }, { className: 'dt-head-center', targets: [ '_all' ] },
] ]