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
switches labels break loops and state variables oh my!
function labeledBreak() {
var state = 'a';
loop:
for(;;) {
switch (state) {
case 'a': state = 'b'; break;
case 'b': state = 'c'; break;
case 'c': state = 'd'; break;
case 'd': state = 'e'; break loop;
}
}
}
function stateVariableBreak() {
var state = 'a';
for(;;) {
switch (state) {
case 'a': state = 'b'; break;
case 'b': state = 'c'; break;
case 'c': state = 'd'; break;
case 'd': state = 'e'; break;
}
if (state = 'e') break;
}
}
function naturalBreak() {
var state = 'a';
for(; state != 'e' ;) {
switch (state) {
case 'a': state = 'b'; break;
case 'b': state = 'c'; break;
case 'c': state = 'd'; break;
case 'd': state = 'e'; break;
}
}
}
function control() {
for(var i = 0; i < 5; i++) {}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
labeled break |
| ready |
state variable break |
| ready |
natural break |
| ready |
control |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.