Giter VIP home page Giter VIP logo

Comments (17)

samdark avatar samdark commented on May 27, 2024 2

Probably you're right...

from yii-debug.

samdark avatar samdark commented on May 27, 2024 2

I'd rather see it defaulted to YII_DEBUG... but otherwise a good idea.

from yii-debug.

vitalyzhakov avatar vitalyzhakov commented on May 27, 2024 1

I have updated the code #12911, please, review it.

from yii-debug.

yii-bot avatar yii-bot commented on May 27, 2024

Issue moved to yiisoft/yii2-debug#153

from yii-debug.

vitalyzhakov avatar vitalyzhakov commented on May 27, 2024

@samdark , why issue moved to debug extension? I think, Yii::beginProfile must be in core files (for example, in
https://github.com/yiisoft/yii2/blob/master/framework/caching/Cache.php) such as https://github.com/yiisoft/yii2/blob/master/framework/db/Command.php#L842

from yii-debug.

dynasource avatar dynasource commented on May 27, 2024

this is a useful indeed.

The question is how to implement this in an optimal & flexible way.
Perhabs we want this to be covered with Events inside the Cache.php. Then developers have more flexibility.

Looking at your current PR yiisoft/yii2#12891, I see that the logging is also triggered on production. Performancewise, this is not preferable. There should at least be a check in place for YII_DEBUG.

If you'd ask me, I would go for the triggering of an Event. Then you can decide in the applications bootstrap.php which Events you want to trigger for your debug-toolbar.

from yii-debug.

vitalyzhakov avatar vitalyzhakov commented on May 27, 2024

Can't understand your idea, please, give me an example of using events.
Checking YII_DEBUG I will add, thank you.

from yii-debug.

dynasource avatar dynasource commented on May 27, 2024

of course:

in bootstrap.php

use yii\base\Event;
use yii\base\View;

Event::on(View::class,View::EVENT_BEFORE_RENDER,function(){
    Yii::beginProfile(Yii::$app->params['RENDER'] ?? Yii::$app->params['RENDER'] = 0,'View::render()');
    Yii::$app->params['RENDER']++;
});
Event::on(View::class,View::EVENT_AFTER_RENDER,function(){
    Yii::endProfile(Yii::$app->params['RENDER']-1);
});

from yii-debug.

samdark avatar samdark commented on May 27, 2024

Triggering events should have even more performance impact than calling profiling methods so I'd keep it as profiling ones only and in debug mode only.

from yii-debug.

dynasource avatar dynasource commented on May 27, 2024

I thought about that, but it can be questioned:
Firstly, is triggering and empty array of events really a performance killer?
Secondly, the total number of cache hits on any page does usually not exceed 5 hits.

Its good to have some benchmarks to be able to properly assess the question about flexibility v.s. performance.

from yii-debug.

samdark avatar samdark commented on May 27, 2024

Firstly, is triggering and empty array of events really a performance killer

Have to measure it. I did that with pre-release 2.0 version. Answer was that it's significant.

Secondly, the total number of cache hits on any page does usually not exceed 5 hits.

Depends on the project very much. I saw projects with 100s of hits.

from yii-debug.

dynasource avatar dynasource commented on May 27, 2024

hmmm...100s is signifant. Then this is no debate anymore. Also, there are alternative solutions thinkable for the debug environment, such as class replacements with Yii::$container->set() with debugging stepping points.

from yii-debug.

kidol avatar kidol commented on May 27, 2024

In other cases profiling doesn't depend on YII_DEBUG. If performance really is a problem, I'd rather see $enableProfiling property which defaults to false.

from yii-debug.

samdark avatar samdark commented on May 27, 2024

yiisoft/yii2#12911

from yii-debug.

rustamwin avatar rustamwin commented on May 27, 2024

Let's move it to the cache package?

from yii-debug.

samdark avatar samdark commented on May 27, 2024

@rustamwin can't we measure time based on data collected via container proxy calls? https://github.com/yiisoft/yii-debug/blob/master/src/Proxy/ProxyLogTrait.php

from yii-debug.

rustamwin avatar rustamwin commented on May 27, 2024

Yes, of course.

from yii-debug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.