Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

perf(autocomplete): Use virtual repeat... #3733

Closed
wants to merge 1 commit into from

Conversation

kseamon
Copy link
Contributor

@kseamon kseamon commented Jul 14, 2015

...and some other optimizations

@kseamon
Copy link
Contributor Author

kseamon commented Jul 14, 2015

I gathered some numbers (All in ms) from the chrome profiler testing dist/demos/autocomplete/demoBasicUsage/index.html, which has 50 repeated items. I'd expect that with a larger data set (say hundreds of items or more), the times would diverge by a lot more.

Startup times:
Old version: 121.6, 109.0, 104.9
With virtual repeat: 112.1, 105.6, 115.2

ctrl.matches (which feeds the repeater) is not populated yet, so we shouldn't expect much change until the user starts typing...

Time to click into textfield and type "aaa":
Old version: 122.6, 124.5, 122.3
With virtual repeat: 46.5, 46.4, 45.0

@jelbourn
Copy link
Member

@robertmesserle

@@ -178,14 +178,18 @@ md-autocomplete {
}
}
}

.md-autocomplete-suggestions-container {
position: absolute !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do this without using !important? I doubt it matters in this case, but if possible, it'd be nice.

@robertmesserle
Copy link
Contributor

LGTM

$$rAF.flush();
element.scope().$apply();
$$rAF.flush();
});
Copy link
Member

Choose a reason for hiding this comment

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

So, I think I get it: You just have to scope.$apply(), then $timeout.flush(), then $$rAF.flush(), then again scope.$apply(), then finally $$rAF.flush() again and...BAM...virtual-repeat ready !!!
Nice !

(Some comments would be also nice here, but I guess that's not very straightforward.)

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL - completely obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as @gkalpak says, the code is 100% self-documenting and not confusing at all.

However, I've added some comments as well.

@kseamon kseamon force-pushed the virtual-autocomplete branch from 8705488 to 9af95cd Compare July 15, 2015 18:25
@ThomasBurleson ThomasBurleson added the pr: merge ready This PR is ready for a caretaker to review label Jul 15, 2015
@ThomasBurleson ThomasBurleson self-assigned this Jul 15, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 0.10.1, 0.10.1-rc2 Jul 15, 2015
@naomiblack naomiblack modified the milestones: 0.10.1, 0.11.0 Aug 10, 2015
@naomiblack naomiblack modified the milestones: 0.12.0, 0.11.0 Aug 14, 2015
@ThomasBurleson
Copy link
Contributor

@kseamon - please rebase and I can merge.

@kseamon kseamon force-pushed the virtual-autocomplete branch from 9af95cd to 99a51c0 Compare August 17, 2015 19:03
@kseamon
Copy link
Contributor Author

kseamon commented Aug 17, 2015

Rebased

@robertmesserle
Copy link
Contributor

@jelbourn This is failing due to tests relating to Calendar, can you take a look and help me merge this in tomorrow?

@jelbourn
Copy link
Member

It's probably because calendar tests need to do the same sequence of flushes / applies.

@ThomasBurleson
Copy link
Contributor

@robertmesserle, @jelbourn - tests still failing:

Firefox 31.0.0 (Mac OS X 10.9.0) md-calendar calendar construction should highlight the selected date FAILED
    Error: [$compile:ctreq] Controller 'mdCalendar', required by directive 'mdCalendarMonth', can't be found!
    http://errors.angularjs.org/1.4.4/$compile/ctreq?p0=mdCalendar&p1=mdCalendarMonth in /Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js (line 68)
    minErr/<@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:68:5
    getControllers@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:8105:1
    getControllers@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:8110:13
    nodeLinkFn@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:8250:1
    compositeLinkFn@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:7638:1
    publicLinkFn@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:7512:30
    createBoundTranscludeFn/boundTranscludeFn@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:7659:11
    controllersBoundTransclude@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:8273:11
    VirtualRepeatController.prototype.getBlock_@/Users/thomasburleson/Documents/projects/Google/projects/material/src/components/virtualRepeat/virtualRepeater.js:630:3
    VirtualRepeatController.prototype.virtualRepeatUpdate_@/Users/thomasburleson/Documents/projects/Google/projects/material/src/components/virtualRepeat/virtualRepeater.js:581:5
    bind/<@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:1185:1
    $watchCollectionAction@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:15618:13
    $RootScopeProvider/this.$get</Scope.prototype.$digest@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:15753:23
    $RootScopeProvider/this.$get</Scope.prototype.$apply@/Users/thomasburleson/Documents/projects/Google/projects/material/node_modules/angular/angular.js:16024:13
    applyDateChange@/Users/thomasburleson/Documents/projects/Google/projects/material/src/components/datepicker/calendar.spec.js:19:5
    @/Users/thomasburleson/Documents/projects/Google/projects/material/src/components/datepicker/calendar.spec.js:243:7

@ThomasBurleson ThomasBurleson added needs: tests and removed pr: merge ready This PR is ready for a caretaker to review summit labels Aug 20, 2015
...and some other optimizations

review
@kseamon kseamon force-pushed the virtual-autocomplete branch from 99a51c0 to 6763327 Compare August 24, 2015 18:17
@kseamon
Copy link
Contributor Author

kseamon commented Aug 24, 2015

@ThomasBurleson @jelbourn Updated - Tests are fixed

@kseamon kseamon closed this in f817193 Aug 24, 2015
@lmadeira
Copy link

Autocomplete with custom template is not work properly after this commit even at: https://material.angularjs.org/HEAD/#/demo/material.components.autocomplete

kennethcachia pushed a commit to kennethcachia/material that referenced this pull request Sep 23, 2015
...and some other optimizations

Closes angular#3733.
@Splaktar Splaktar added the needs: unit tests This PR needs unit tests to cover the changes being proposed label Mar 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: unit tests This PR needs unit tests to cover the changes being proposed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants