jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
var ranges = [];
for( var i = 0; i < 10000; i++ ){
var start = Math.random() * 1000000;
var end = start + Math.random() * (1000000-start);
ranges.push({start:start, end: end});
}
var sortedByStart = ranges.sort(function(range_a, range_b){
return range_b.start - range_a.start;
});
sortedByStart.forEach(function(range, index){
range.startIndex = index;
});
var sortedByEnd = ranges.sort(function(range_a, range_b){
return range_b.end - range_a.end;
});
sortedByEnd.forEach(function(range, index){
range.endIndex = index;
});
function findLowestHigher(value, list, property){
low = 0;
high = list.length;
while( low < high ){
var test = Math.floor(low + (high - low) / 2);
if( list[test][property] > value ){ high = test; }
else{ low = test + 1; }
}
return low;
}
function findStart(value){
return findLowestHigher(value, sortedByStart, 'start');
}
// finds the index of the lowest end higher than value
function findEnd(value){
return findLowestHigher(value, sortedByEnd, 'end');
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Linear Search |
| ready |
Dual Binary Search and Merge |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.