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 prime( num ) { var check = Math.ceil( num/2 ), reg = /\./; while( --check > 1 ) { if ( !reg.test( num/check+"" ) ) { return false; } } return true; }
function primeSqrIndexOf( num ) { var check = Math.ceil( Math.sqrt(num)+1 ); while( --check > 1 ) { if ( ( num/check+"" ).indexOf('.') === -1 ) { return false; } } return true; }
function primeBest( num ) { var check = Math.ceil( Math.sqrt(num) ); while( --check > 1 ) { if ( ( num/check+"" ).indexOf('.') === -1 ) { return false; } } return true; }
function primeSqr( num ) { var check = Math.ceil( Math.sqrt(num)+1 ), reg = /\./; while( --check > 1 ) { if ( !reg.test( num/check+"" ) ) { return false; } } return true; }
function primeSqrMod( num ) { for( var check = Math.floor( Math.sqrt( num ) ); check>1; check-- ) if ( num % check ) return false; return true; }
function primeBestEql( num ) { var check = Math.ceil( Math.sqrt(num) ), test; while( --check > 1 ) { test = num/check; if ( ~~test === test ) { return false; } } return true; }
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
prime iterated |
| ready |
primeSqr |
| ready |
primeSqrMod |
| ready |
primeSqrIndexOf |
| ready |
primeBest |
| ready |
primeBestEql |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.