C
C
chesar2015-03-13 15:39:07
Yii
chesar, 2015-03-13 15:39:07

Number of disk system accesses of a standard php template engine?

generate view
controller.php

return $this->render('date', ['data' => $data, 'date' => $date]);

Option 1: view-date.php
<section class="article-list">
    <h5><?= $date?> </h5>
    <?php foreach ($data as $news)  echo $this->render('_list_item', ['news'=>$news]); ?>
</section>

Option 2: view-date.php
<section class="article-list">
    <h5><?= $date?> </h5>
    <?php foreach ($data as $news) :  ?>
    <div class="article"> <?php /* код из _list_item.php */ ?> </div>
    <?php endforeach; ?>
</section>

The YII2 framework is used, the main code responsible for rendering:
public function renderPhpFile($_file_, $_params_ = [])
    {
        ob_start();
        ob_implicit_flush(false);
        extract($_params_, EXTR_OVERWRITE);
        require($_file_);

        return ob_get_clean();
    }

In the first variant, the generation of the list element in a separate view, because it is used in some other places in the project - it is quite convenient to make changes. But the lists are large and the question is: how often does php access this file? Is there a request to the disk system for each element of the array or once? Does opcache help?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
He11ion, 2015-03-13
@He11ion

I advise you to put something like https://github.com/rlerdorf/opcache-status and watch the status of the opcache, well, you can simply collect statistics - turn off the opcache - collect again - clearly see if it works.

F
FanatPHP, 2015-03-13
@FanatPHP

helps

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question