Skip to content

Commit

Permalink
Fixed issue where we were trying to re-add attributes, already added …
Browse files Browse the repository at this point in the history
…by a subclass.

This ate into our gains a little bit (compared to prior attrs-perf commits), but still
substantially better than 3.8.1. Numbers below.

Also validated that the issues highlighted by Tripps charts test case are
accounted for. See #453 (comment)

All tests pass:

attrs-perf/src $ yogi test
[Total]: Passed: 10717 Failed: 0 Total: 10802 (ignored 85) (8 minutes, 19 seconds)

NOTE: Had to make a low-level perf optization call based on FF being an major
outlier in the following test: http://jsperf.com/in-vs-hasownproperty/6. Hence
included FF numbers below also. We can revisit if required - flip-flopped between
the 2 many times, and chose hop, because it saved some of the gains we lost for
the major chunk (webkit) of target browsers. Worth pinging FF about?

Chrome 25:

This Commit

BaseCore x 160,543 ops/sec ±0.68% (94 runs sampled)
MyBaseCore x 149,699 ops/sec ±1.15% (91 runs sampled)
MyBaseCore with 10 simple value attributes x 45,741 ops/sec ±1.43% (93 runs sampled)
MyBaseCore with 20 varied attributes x 7,791 ops/sec ±5.81% (61 runs sampled)
MyBaseCore with 20 varied attributes (using perf. best practices) x 18,961 ops/sec ±1.17% (90 runs sampled)
MyBaseCore with 10 simple value attributes - set x 2,439,898 ops/sec ±0.35% (94 runs sampled)
MyBaseCore with 10 simple value attributes - get x 10,296,544 ops/sec ±0.61% (92 runs sampled)

Prior Commit

BaseCore x 167,934 ops/sec ±1.17% (95 runs sampled)
MyBaseCore x 164,318 ops/sec ±1.40% (93 runs sampled)
MyBaseCore with 10 simple value attributes x 52,033 ops/sec ±1.19% (95 runs sampled)
MyBaseCore with 20 varied attributes x 8,312 ops/sec ±6.99% (55 runs sampled)
MyBaseCore with 20 varied attributes (using perf. best practices) x 23,259 ops/sec ±1.35% (92 runs sampled)
MyBaseCore with 10 simple value attributes - set x 2,780,588 ops/sec ±3.29% (91 runs sampled)
MyBaseCore with 10 simple value attributes - get x 10,517,876 ops/sec ±0.40% (92 runs sampled)

3.8.1

BaseCore x 59,459 ops/sec ±1.42% (94 runs sampled)
MyBaseCore x 54,524 ops/sec ±1.70% (93 runs sampled)
MyBaseCore with 10 simple value attributes x 21,651 ops/sec ±1.22% (91 runs sampled)
MyBaseCore with 20 varied attributes x 6,255 ops/sec ±5.47% (62 runs sampled)
MyBaseCore with 20 varied attributes (using perf. best practices) x 12,244 ops/sec ±1.45% (92 runs sampled)
MyBaseCore with 10 simple value attributes - set x 533,183 ops/sec ±0.51% (95 runs sampled)
MyBaseCore with 10 simple value attributes - get x 2,373,572 ops/sec ±0.38% (88 runs sampled)

Firefox 19:

This Commit

BaseCore x 59,213 ops/sec ±0.95% (86 runs sampled)
MyBaseCore x 54,453 ops/sec ±0.86% (87 runs sampled)
MyBaseCore with 10 simple value attributes x 29,714 ops/sec ±2.64% (89 runs sampled)
MyBaseCore with 20 varied attributes x 11,533 ops/sec ±0.93% (89 runs sampled)
MyBaseCore with 20 varied attributes (using perf. best practices) x 16,562 ops/sec ±0.93% (88 runs sampled)
MyBaseCore with 10 simple value attributes - set x 923,897 ops/sec ±0.75% (96 runs sampled)
MyBaseCore with 10 simple value attributes - get x 5,773,198 ops/sec ±0.92% (92 runs sampled)

3.8.1

BaseCore x 24,210 ops/sec ±1.79% (79 runs sampled)
MyBaseCore x 24,322 ops/sec ±2.74% (79 runs sampled)
MyBaseCore with 10 simple value attributes x 14,059 ops/sec ±1.49% (92 runs sampled)
MyBaseCore with 20 varied attributes x 6,645 ops/sec ±0.92% (90 runs sampled)
MyBaseCore with 20 varied attributes (using perf. best practices) x 8,001 ops/sec ±0.57% (91 runs sampled)
MyBaseCore with 10 simple value attributes - set x 334,317 ops/sec ±5.55% (93 runs sampled)
MyBaseCore with 10 simple value attributes - get x 2,045,595 ops/sec ±0.79% (95 runs sampled)
  • Loading branch information
sdesai committed Mar 1, 2013
1 parent 361dfca commit 7b7c9c3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/base/js/BaseCore.js
Expand Up @@ -333,19 +333,27 @@
subAttrs,
subAttrPath,
attr,
attrCfg,
filtered = this._filteredAttrs,
attrs = clazz.ATTRS;

if (attrs) {
for (attr in attrs) {
if (allCfgs[attr]) {
attrCfg = allCfgs[attr];

// Using hasOwnProperty, since it's faster (for the 80% case where filtered doesn't have attr) for the majority
// of browsers, FF being the major outlier. http://jsperf.com/in-vs-hasownproperty/6. May revisit.
if (attrCfg && !filtered.hasOwnProperty(attr)) {

if (!cfgs) {
cfgs = {};
}

// PERF TODO:
// Revisit once all unit tests pass for further optimizations. See if we really need to isolate this.
cfg = cfgs[attr] = _wlmix({}, allCfgs[attr], this._attrCfgHash());
cfg = cfgs[attr] = _wlmix({}, attrCfg, this._attrCfgHash());

filtered[attr] = true;

val = cfg.value;

Expand Down Expand Up @@ -626,6 +634,8 @@
attrCfgs = this._getAttrCfgs(),
cl = classes.length - 1;

this._filteredAttrs = {};

for (ci = cl; ci >= 0; ci--) {

constr = classes[ci];
Expand Down Expand Up @@ -659,6 +669,8 @@
}
}
}

this._filteredAttrs = null;
},

/**
Expand Down

0 comments on commit 7b7c9c3

Please sign in to comment.