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
A javascript implementation of the Haversine distance formula is given here.
This test case experiments with improving the performance of this function, for when the function will be called thousands of times and performance matters.
<script>
var TO_RAD = Math.PI / 180;
function toRad(deg) {
return deg * TO_RAD;
}
var coords = new Array();
function randomLat() {
return Math.random() * 180 - 90;
}
function randomLong() {
return Math.random() * 360 - 180;
}
for (var i = 0; i < 5000; i++) {
coords.push([randomLat(), randomLong(), randomLat(), randomLong()]);
}
function compute(coord, f) {
return f(coord[0], coord[1], coord[2], coord[3]);
}
function test(f) {
for (var i = 0; i < coords.length; i++) {
var coord = coords[i];
compute(coord, f);
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Original |
| ready |
Optimised1 |
| ready |
Optimised2 |
| ready |
Optimised3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.