diff --git a/benchmark.pl b/benchmark.pl index 26a5a98..9876385 100755 --- a/benchmark.pl +++ b/benchmark.pl @@ -125,20 +125,62 @@ function initPlots() { ctx.stroke(); } } + document.getElementById('sort_orig').onclick = function() { + sort(function(e) { + return parseFloat(e.getAttribute("data-index")); + }); + }; + document.getElementById('sort_median').onclick = function() { + sort(function(e) { + return -parseFloat(e.getAttribute("data-median")); + }); + }; + document.getElementById('sort_mean').onclick = function() { + sort(function(e) { + return -parseFloat(e.getAttribute("data-mean")); + }); + }; +} +function sort(keyfn) { + var rows = document.getElementsByTagName("tr"); + var trs = []; + for (var i = 0; i < rows.length; i++) + trs.push(rows[i]); + trs.sort(function(a,b) { + var akey = keyfn(a); + var bkey = keyfn(b); + return akey < bkey ? -1 : akey > bkey ? +1 : 0; + }); + var parent = trs[0].parentElement; + for (var i = 0; i < trs.length; i++) + parent.removeChild(trs[i]); + for (var i = 0; i < trs.length; i++) + parent.appendChild(trs[i]); } //]]>
Sort order: + + +
Preset | |
---|---|
", &escape($preset), " |