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
const _b_ = {
None: {}
}
let _trace_fct = _b_.None
$A = {
enter_frame: function(frame){
return _trace_fct },
trace_return: function(result) { console.log('return', result) },
trace_exception: function() { console.log('enabled'); }
};
function foo_A(a,b) {
let frame = []
frame.$f_trace = $A.enter_frame(frame)
try {
let result = a+b
if(frame.$f_trace !== _b_.None){
$A.trace_return(result)
}
return result;
} catch(e) {
if(frame.$f_trace !== _b_.None){
frame.$f_trace = $A.trace_exception()
}
}
}
/*** B ***/
$B = {
enter_frame: function(frame){
if( _trace_fct === _b_.None )
return {
trace_return: function(_arg){},
trace_exception: function(){}
};
}
};
function foo_B(a,b) {
let frame = []
const trace = frame.$f_trace = $B.enter_frame(frame)
try {
let result = a+b
trace.trace_return(result)
return result;
} catch(e) {
trace.trace_exception()
}
}
/*** C ***/
function foo_C(a,b) {
let frame = []
$B.enter_frame(frame)
try {
let result = a+b
return result;
} catch(e) {}
}
/*** D ***/
const obj = {
trace_return: function(_arg){},
trace_exception: function(){}
};
$D = {
enter_frame: function(frame){
return obj;
}
};
function foo_D(a,b) {
let frame = []
const trace = $D.enter_frame(frame)
try {
let result = a+b
trace.trace_return(result)
return result;
} catch(e) {
trace.trace_exception()
}
}
/*** E ***/
const NO_TRACE = function(_arg){};
NO_TRACE.trace_exception = function(){};
function getNO_TRACE() { return NO_TRACE }
$E = {
enter_frame: getNO_TRACE
};
function foo_E(a,b) {
let frame = []
const trace = $E.enter_frame(frame)
try {
let result = a+b
trace(result)
return result;
} catch(e) {
// Or do something else, we don't care if exceptions are less performant
trace.trace_exception()
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Brython |
| ready |
Functions instead of conditions |
| ready |
Mode performance |
| ready |
Functions instead of conditions - precomputed |
| ready |
Function instead of conditions - no objects |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.