Comments (17)
Probably you're right...
from yii-debug.
I'd rather see it defaulted to YII_DEBUG... but otherwise a good idea.
from yii-debug.
I have updated the code #12911, please, review it.
from yii-debug.
Issue moved to yiisoft/yii2-debug#153
from yii-debug.
@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.
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.
Can't understand your idea, please, give me an example of using events.
Checking YII_DEBUG I will add, thank you.
from yii-debug.
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.
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.
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.
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.
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.
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.
from yii-debug.
Let's move it to the cache package?
from yii-debug.
@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.
Yes, of course.
from yii-debug.
Related Issues (20)
- Add support `yiisoft/view` version `^5.0`
- Remove yiisoft/cache dependecy HOT 2
- Actualize docs
- Add support `yiisoft/view` version `^6.0`
- Callback in `MiddlewareCollector` can be Closure, but supports array only
- Remove dependency on yii-filesystem
- The "_complete" command gets into the debugger HOT 2
- Sniff all cURL requests
- CLI debug commands HOT 6
- Increase psalm level to 1
- update links
- Timeline collector
- update irc link
- Export/Import results HOT 1
- Multi server support for debug panel HOT 4
- [RFC] Debugger design draft HOT 11
- Don't collect requests related to yii-debug-api
- Debug always logs the same amount of memory used HOT 2
- Trim git history
- Debugger crashes if console command can not be initialized
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii-debug.