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

Environment::set() is slow #1270

Open
fedeisas opened this issue Mar 13, 2016 · 1 comment
Open

Environment::set() is slow #1270

fedeisas opened this issue Mar 13, 2016 · 1 comment

Comments

@fedeisas
Copy link

Hi!

In our app we (ab)use Environment::set() when bootstrapping to set all of our site's configuration. We set some defaults, and then depending on our environment (prod/test/dev) we overwrite some of those.

I was just trying to improve my app's performance and I've found that Environment::set() uses Set::merge() which is kinda slow.

Sometimes you want to set some configuration overwriting the existing values. Perhaps I'm misusing this class.

Example:

<?php
// This is slow
Environment::set(true, ['assets' => $foo + Environment::get('assets')]);

// This is fast
$bar = $foo + Environment::get('assets');
Environment::set(true, ['assets' => null]);
Environment::set(true, ['assets' => $bar]);
@mariuswilms
Copy link
Member

Initial set has been minimally optimized in 1e7b327. Set::merge seems already pretty optimized, but maybe someone might want to give it a try. @fedeisas Benchmarks showing the differences (and where time is spent) between the two cases outlined in your report would help.

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

No branches or pull requests

3 participants