assert vs throw
JavaScript performance comparison
Test case created by Qubyte
Info
Does assert(!err, "setup failure"); perform better or worse than if (err) throw (err);?
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Testing in unknown unknown
| Test |
Ops/sec |
assert |
var rand = Math.random(); var error = rand > 0.5 ? new Error('this is a random number ' + rand) : false; try { assert(!error, 'assertion failed'); } catch (e) {}
|
pending… |
if (error) throw (error) |
var rand = Math.random(); var error = rand > 0.5 ? new Error('this is a random number ' + rand) : false; try { if (error) { throw (error); }; } catch (e) {}
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
Compare results of other browsers
0 comments