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
<script>
function LatLng(lat, lng, alt) {
lat = parseFloat(lat);
lng = parseFloat(lng);
if (isNaN(lat) || isNaN(lng)) {
throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
}
this.lat = lat;
this.lng = lng;
if (alt !== undefined) {
this.alt = parseFloat(alt);
}
};
function LatLng2(lat, lng, alt) {
if (isNaN(lat) || isNaN(lng)) {
throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
}
this.lat = +lat;
this.lng = +lng;
if (alt !== undefined) {
this.alt = +alt;
}
};
function latLng(a, b) {
if (a instanceof LatLng) {
return a;
}
if (Array.isArray(a)) {
if (typeof a[0] === 'number' || typeof a[0] === 'string') {
return new LatLng(a[0], a[1], a[2]);
} else {
return null;
}
}
if (a === undefined || a === null) {
return a;
}
if (typeof a === 'object' && 'lat' in a) {
return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon);
}
if (b === undefined) {
return null;
}
return new LatLng(a, b);
};
function latLng2(a, b) {
if (a instanceof LatLng2) {
return a;
}
if (Array.isArray(a) && typeof a[0] !== 'object') {
if (a.length === 3) {
return new LatLng2(a[0], a[1], a[2]);
} else {
return new LatLng2(a[0], a[1]);
}
}
if (a === undefined || a === null) {
return a;
}
if (typeof a === 'object' && 'lat' in a) {
return new LatLng2(a.lat, 'lng' in a ? a.lng : a.lon);
}
if (b === undefined) {
return null;
}
return new LatLng2(a, b);
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
0.7 |
| ready |
master |
| ready |
0.7 factory |
| ready |
master factory |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.