try vs check null vs noop
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var noop = function(a, b) {};
var real1 = function(a, b) {
return a > b
};
var real2 = function(a, b) {
return a < b
};
var real3 = function(a, b) {
return a == b
};
var null_suit = [];
var noop_suit = [];
var n = 100;
while (n--) {
null_suit.push(real1, real2, null, real3, null, null);
noop_suit.push(real1, real2, noop, real3, noop, noop);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Is Null |
|
pending… |
Is Function |
|
pending… |
try |
|
pending… |
noop |
|
pending… |
!= noop |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments