2011-10-07 18:27:49 +00:00
|
|
|
describe('perf misc', function() {
|
|
|
|
|
it('operation speeds', function() {
|
2011-03-23 16:33:29 +00:00
|
|
|
perf(
|
2011-10-07 18:27:49 +00:00
|
|
|
function typeByTypeof() { return typeof noop == 'function'; }, // WINNER
|
2011-03-23 16:33:29 +00:00
|
|
|
function typeByProperty() { return noop.apply && noop.call; },
|
|
|
|
|
function typeByConstructor() { return noop.constructor == Function; }
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
it('property access', function() {
|
2011-03-23 16:33:29 +00:00
|
|
|
var name = 'value';
|
|
|
|
|
var none = 'x';
|
|
|
|
|
var scope = {};
|
|
|
|
|
perf(
|
2011-10-07 18:27:49 +00:00
|
|
|
function direct() { return scope.value; }, // WINNER
|
2011-03-23 16:33:29 +00:00
|
|
|
function byName() { return scope[name]; },
|
2011-10-07 18:27:49 +00:00
|
|
|
function undefinedDirect() { return scope.x; },
|
2011-03-23 16:33:29 +00:00
|
|
|
function undefiendByName() { return scope[none]; }
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|