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

[BUGFIX beta] Set models array length in link-to. #12546

Merged
merged 1 commit into from
Nov 5, 2015

Conversation

nathanhammond
Copy link
Member

We know the array length in advance so we should set it.

Proof:
http://jsperf.com/array-push-new-literal

@stefanpenner
Copy link
Member

LGTM

@@ -769,7 +769,7 @@ let LinkComponent = EmberComponent.extend({
this.set('queryParams', queryParams);

// 4. Any remaining indices (excepting `targetRouteName` at 0) are `models`.
let models = [];
let models = new Array(params.length - 1);
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be throwing an error when params is empty.

screenshot

Copy link
Member

Choose a reason for hiding this comment

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

if params are empty, we may want to skip allocating and later traversing at all.

Copy link
Member

Choose a reason for hiding this comment

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

ya, agreed

@rwjblue
Copy link
Member

rwjblue commented Nov 2, 2015

Once that last issue is fixed, can you prefix with [BUGFIX beta]? Seems pretty safe to pull down into beta, and we'll take all the perfs we can get!

@stefanpenner
Copy link
Member

It would be nice if provided perfs had demonstrable improvements in ember. An example or benchmark illustrating this improvement would be nice.

@krisselden
Copy link
Contributor

@stefanpenner agreed, often micro benchmarks like this have no noticeable impact on a macro benchmark due to the improved code being a small percentage of the macro case. I'm fine with merging but am curious if this has any impact on a benchmark of list with link-to components.

We know the array length in advance so we should set it.

Proof:
http://jsperf.com/literal-vs-new-23/9
@nathanhammond
Copy link
Member Author

In emberperf it is about 2% faster across multiple runs, presumably by just pulling it out into a function which can be optimized separately, but that doesn't exercise the models use case where we should actually get our performance win.

Tests pass now, tagged correctly.

Ember Version: link-to modifications

.---------------------------------------------------------------.
|               Ember Performance Suite - Results               |
|---------------------------------------------------------------|
|           Name           | Speed  | Error  | Samples |  Mean  |
|--------------------------|--------|--------|---------|--------|
| Render List with link-to |   7.23 | 403.89 |      91 | 138.26 |
| Render link-to           | 379.13 |   5.93 |    1010 |   2.64 |
'---------------------------------------------------------------'

Ember Version: Canary

.---------------------------------------------------------------.
|               Ember Performance Suite - Results               |
|---------------------------------------------------------------|
|           Name           | Speed  | Error  | Samples |  Mean  |
|--------------------------|--------|--------|---------|--------|
| Render List with link-to |   6.87 | 528.64 |      86 | 145.51 |
| Render link-to           | 371.58 |   4.84 |    1004 |   2.69 |
'---------------------------------------------------------------'

@nathanhammond nathanhammond changed the title [Performance] Set models array length in link-to. [BUGFIX beta] Set models array length in link-to. Nov 3, 2015
@mixonic
Copy link
Member

mixonic commented Nov 5, 2015

Thanks @nathanhammond :-)

mixonic added a commit that referenced this pull request Nov 5, 2015
[BUGFIX beta] Set models array length in link-to.
@mixonic mixonic merged commit 867ca6a into emberjs:master Nov 5, 2015
@nathanhammond nathanhammond deleted the patch-1 branch November 21, 2015 09:06
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.

5 participants