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
Is it possible to fool method jit to think a function is hot by calling it with an attribute that causes it to skip the hard working?
This will not fool the tracing jit in firefox for sure, but seems to work in chrome
<script>
var payload=[123,123,123,123,12,312,312,31,231,23,12,312,312,31,23,123,12,312,31,231,23,123,123,12,312,31,23,123,12,312,31,231,23,123,12,312,31,23,123,123,12,31,231,23,12,312,31,23,12,31,231,23,123,12,31,23,123,12,31,231,23,12,31,231,23,123,12,31,23,12,312,31,23,12,312,31,23,12,312,31,23,1323,12,31,23,12,312,31,23,12,31,23,12,312,3,12,312,31,23,123,12,31,23,12,312,31,23,123,12,31,23,12,31,231,23,12,31,23,1]
payload.concat(payload,payload,payload);
function f1(skip){
if(skip){ return }
var a='';
for(var i=0;i<payload.length;i+=1){
a+=payload[i]*888;
}
}
function f2(skip){
if(skip){ return }
var a='';
for(var i=0;i<payload.length;i+=1){
a+=payload[i]*888;
}
}
function f3(skip){
if(skip){ return }
var a='';
for(var i=0;i<payload.length;i+=1){
a+=payload[i]*888;
}
}
for(var q=0;q<50000;q+=1){
f2(true);//fast way to heat up
}
for(var q=0;q<50000;q+=1){
f3();//just like normal use
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
no hack |
| ready |
with hack |
| ready |
control if jit works as I guessed |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.