S
S
Sergey Zelensky2015-11-03 11:04:24
PHP
Sergey Zelensky, 2015-11-03 11:04:24

How to optimize the code, what is the best way to do it?

there is this piece of code

foreach ($configuration as $module => $moduleSettings) {
      if (!class_exists($module, false)) {
        self::setUnit($module, new $module($moduleSettings));
      }
      timeRun($t++);
    }

it takes a little more than a second to execute it, the problem is in
new $module, how can you reduce the execution time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Khomenko, 2015-11-03
@SergeyZelensky-Rostov

Don't do new $module :)
There is nothing to optimize in this snippet. Look at the constructors of all $modules, they need to be optimized. Also take a look at setUnit...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question