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>
// https://github.com/sstephenson/prototype/blob/master/src/prototype/lang/string.js#L539
// http://stackoverflow.com/questions/202605/repeat-string-javascript/2433358#2433358
function prototypejs( n ) {
return n < 1 ? '' : new Array( n + 1 ).join( this.valueOf() )
}
// http://stackoverflow.com/q/202605/489553
// optimized: this.valueOf(), while loop
function pushjoin( n ) {
var result = [], pattern = this.valueOf(), i = n
while (i--) result.push(pattern)
return result.join('')
}
// http://stackoverflow.com/questions/202605/repeat-string-javascript/202626#202626
// optimized: this.valueOf(), while loop
function xn( n ) {
var result = '', pattern = this.valueOf(), i = n
while ( i-- ) result += pattern
return result
}
// http://stackoverflow.com/questions/202605/repeat-string-javascript/4152613#4152613
function grow( n ){
var result = ''
var pattern = this
while ( n > 0 ) {
if ( n & 1 ) result += pattern
n >>= 1
pattern += pattern
}
return result
}
// final: growing pattern + prototypejs check (n < 1)
function final( n ) {
if ( n < 1 ) return ''
var result = '', pattern = this.valueOf()
while ( n > 0 ) {
if ( n & 1 ) result += pattern
n >>= 1, pattern += pattern
}
return result
}
</script>
var n = 0x1000
Ready to run.
Test | Ops/sec | |
---|---|---|
prototypejs |
| ready |
pushjoin |
| ready |
xn |
| ready |
grow |
| ready |
final |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.