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
Test performance hit of calling x.hasOwnProperty()
in a for
-in
loop.
Example using the Benchmark.params
object, which contains parameters and values from the URL hash. Try #count=500
or #count=750
.
<script>
var hasOwn = {}.hasOwnProperty,
MyObj;
function setup() {
var i = -1,
result = {},
count = Benchmark.params.count || 50; // Always provide default values!
while (++i < count) {
result[i] = i;
}
i = 0;
while (++i < 4) {
document.getElementById('extra-' + i).innerHTML = '(' + count + ')';
}
return result;
}
MyObj = setup();
// The init() function is pure magic.
// When it’s available, it will be executed before every test,
// and also upon `hashchange`.
// See http://mths.be/aid
function init() {
// Output Benchmark.params to the console if available
window.console && console.log(Benchmark.params);
myObj = setup();
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
With hasOwnProperty |
| ready |
With Generic |
| ready |
Without |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.