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
isInt() a native JS function vs isInteger a regex based function
<script>
function isInt(x) {
var y = parseInt(x);
if (isNaN(y)) return false;
var sign = x.toString().charAt(0);
if (sign == "+" && x == ("+" + y)) {
return true;
}
else if (x == y) {
return true;
}
else return false;
}
function isIntegerOLD(s) {
return (s.toString().search(/^[-]?[0-9]+$/) == 0);
}
function isInteger(s) {
return (s.toString().search(/^[-+]?[0-9]+(\.[0]*)?$/) == 0);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
isInt positive Test |
| ready |
isInteger positive Test |
| ready |
isInt negative Test |
| ready |
isInteger negative Test |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.