A
A
AlikDex2015-09-09 22:58:25
Yii
AlikDex, 2015-09-09 22:58:25

Why does yii2 take such a long time to generate templates?

drove, means zatestit this business without caching. So the generation of data for the template takes about 0.06c. Too much of course, but tolerable. But the template with ListView and other standard widgets builds the page already 0.220c on average (for 30 news, a la blozhik). How so? They are positioning themselves as superfast?! How to speed it up? (without caching, so that it is less than 0.1c, at least 0.099)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2015-09-10
@27cm

They are positioning themselves as superfast?!

Every first framework positions itself this way, no one wants to be a brake.
Yii debug toolbar and debugger
XDebug profiler
XHProf
What is the performance of yii2 and laravel?

L
LAV45, 2015-09-11
@LAV45

To begin with, look at what the debug panel displays
How much memory it consumes, how many queries it makes to the database.
1) If the number of requests goes off scale (>> 10) check whether all related data has been connected.
For example

News::find()
    ->with([
        'author.profile',
        'category',
        'comments',
        // И остальные
    ])
    ->limit(30)
    ->all()

Thus, during a News request, all related data will be immediately received.
Instead of
SELECT * FROM author WHERE id = 1;
SELECT * FROM author WHERE id = 2;
SELECT * FROM author WHERE id = 5;

Must group all requests into one
News::find()
    ->with([...])
    ->asArray()
    ->limit(30)
    ->all()

But then you will receive all the data not in the form of an object, but in the form of an array, which will help save > 50% of the RAM.
PS "You don't like cats?! You just don't know how to cook them!"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question