New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved the Timer and tagged it as API #7760
Conversation
In which plugins is the Timer API used? From the sound it doesn't seem like needed as an API? |
@tsteur FYI you can see the inspection output here http://builds-artifacts.piwik.org/protected/inspections.all/2015-04-04/inspections/all_inspections.out - it's used in VisitorGenerator |
Maybe same applies here as in #7790 (comment) If possible, I would like to avoid making this a public API (to keep the list of available APIs "short") but if needed I'm ok with it. |
The idea is that this isn't a Piwik API, it's a component. Like the Symfony Stopwatch has nothing to do with the framework, the Timer has nothing to do with Piwik. I've considered replacing it with the Stopwatch component but it wasn't worth it because we use things that aren't available, and the Stopwatch is more complex. I have also searched packagist and considered all other alternatives, but not worth it imo. That's why I moved it in another namespace: later we can move it into a separate repo. Hope that clears things up. |
It doesn't really make a difference for me whether it is a component or not... What I meant is marking it as |
@tsteur @mnapoli How would you feel about adding an
? The method would use Timer internally, and print out the success message w/ the elapsed time. This way, we provide an easy way for commands to spit out the time (which seems a common need for long running commands) w/o exposing the Timer class. |
I'm not sure, it probably depends on the use case. If someone wants to know the time the command took, one could simply use the Linux command If we want to print it always after command execution for specific commands then such a method could be helpful. Although I'm not sure if I'd prefer to use |
This doesn't help if you're timing individual steps, such as optimizing multiple tables (which allows users to see progress + get an idea of how long the next step will take).
I have no idea what you mean by this, but how would it be easier than using a callback? |
That's why I asked for the use case. I don't see this in the
I don't see a need for a callback here. It makes it rather more complicated to understand, to debug and profile etc. It would be easier to not have a callback since you'd simply write a command as usual:
As you want to time different operations as you just said this would not help you there. I would personally either use the |
A helper could be exposed via |
I'd rather remove usage of such timer class to replace it with manually using |
While working on #7569 (removing calls to non-api stuff) I saw that the Timer was used in some plugins but it's not tagged as
@api
.I tagged the Timer as API but before that I cleaned it up a bit:
Piwik\Timer
namespace: it avoids cluttering the rootPiwik\
namespace with stuff unrelated to Piwik itself, and it allows to move it to an external component later without any bc breakBy the way I now realize that git didn't pick up the "move" operation and instead deleted/recreated the file, that wasn't planned sometimes git can be a bit difficult about that :/
PR targeted at 2.14, don't merge in 2.13?