Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Cache for tagname operations. #12309

Merged
merged 1 commit into from
Sep 9, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Sep 8, 2015

  • Avoid running a regexp match against the same string many times.
  • Avoid searching the same string for a dash many times.
  • Change Cache to use new EmptyObject() since we do not need delete support, we don't need to force into "slow mode"

Timing shows a small improvement (tested against ef4/initial-render-perf):

Before: 164ms average (for 10 runs)
After: 159ms average (for 10 runs)

* Avoid running a regexp match against the same string many times.
* Avoid searching the same string for a dash many times.
* Change `Cache` to use `new EmptyObject()` since we do not need
  `delete` support, we don't need to force into "slow mode"
@rwjblue
Copy link
Member Author

rwjblue commented Sep 8, 2015

@stefanpenner - Can you 👍 / 👎 the changes to ember-metal/cache?

import Cache from 'ember-metal/cache';

var IS_ANGLE_CACHE = new Cache(1000, function(key) {
return key.match(/^(@?)<(.*)>$/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this RegExp looks like kirby 👍

@stefanpenner
Copy link
Member

@rwjblue looks good, Cache actually has internal instrumentation. Can you share the hit/miss info?

@rwjblue
Copy link
Member Author

rwjblue commented Sep 9, 2015

After running the "Render for 10 seconds" perf test on ef4/initial-render-perf:

screenshot

Both caches have: 14443 hits and 5 misses

@stefanpenner
Copy link
Member

Both caches have: 14443 hits and 5 misses

nice

rwjblue added a commit that referenced this pull request Sep 9, 2015
@rwjblue rwjblue merged commit 2bca168 into emberjs:master Sep 9, 2015
@rwjblue rwjblue deleted the use-cache-for-tagname-operations branch September 9, 2015 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants