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

Memoize module make functions #147

Closed
rehno-lindeque opened this Issue Jan 27, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@rehno-lindeque
Contributor

rehno-lindeque commented Jan 27, 2015

I've been investigating the loading for our elm widgets...

It appears to me that when several widgets are instantiated (embedded), repeated calls to make for a large module is very slow. In particular, Bootstrap.Html.make() takes a large amount of time:

timeline

One way of testing this quickly is as follows:

for (var i = 0; i < 100; ++i) {
    Elm.Bootstrap.Html.make({});
}

The above takes 12.68s on my laptop.

One quick solution might be to memoize the make function. The generated function currently looks like this...

Elm.Bootstrap.Html.make = function (_elm) { ... }

...I'm not 100% sure if it would be necessary to memoize the function based on the incoming _elm environment, but it seems like that shouldn't be necessary. One edge case is if someone is uses different versions of the same package for different embedded widgets.

@rehno-lindeque

This comment has been minimized.

Show comment
Hide comment
@rehno-lindeque

rehno-lindeque Jan 27, 2015

Contributor

Oops wrong place for this issue: moved to elm/compiler#888

Contributor

rehno-lindeque commented Jan 27, 2015

Oops wrong place for this issue: moved to elm/compiler#888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment