Closed (outdated)
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
7 Mar 2013 at 19:15 UTC
Updated:
25 Jun 2025 at 17:42 UTC
Jump to comment: Most recent
Comments
Comment #1
robloach#1935970: Convert timer_* to a utility class and convert tests to phpunit
Comment #2
ParisLiakos commentedblocker is in
i think this issue would be nice for someone that wants to get familiar with composer
Comment #3
damiankloip commentedI think I will check this out today.
Comment #4
sunMight be best to wait for the complete removal of the deprecated procedural functions in #2173335: Remove deprecated timer_* functions (which hopefully lands soon)
But in general, totally +1 → less code to maintain.
There's only one major difference: Stopwatch is not a static class, you need to instantiate an actual object.
You have to retain it in your local scope, and if necessary, you need to pass the object forward to child scopes.
This means that you cannot easily do what we're doing in some places now; e.g., starting a 'page' timer in _drupal_bootstrap_configuration() and consuming that in any other spot of the application.
That is, unless we'd register it as a synchronized service and persist it across container rebuilds, I guess.
But aside from that looks like the API is fairly similar:
Comment #5
dawehnerOne problem is that _drupal_bootstrap_configuration() currently calls the Timer::start('page') right after the classloader got initialized in order to let tools like devel comes in as fast as possible.
I would really wonder whether this needs to be done that early in the bootstrap. Usually you don't use devel to figure out bootstrap performance but do some actual measurements with xhprof.
In the symfony world they replace the http kernel to measure performance at that level.
Comment #6
webchickI can't see any value in breaking APIs (again) for this, really. What is the gain? Is StopWatch in Symfony's list of BC-compatible components? Etc. To me this feels like 9.x material. We shouldn't be looking for APIs to break at this point.
Comment #7
webchickDoing that, unless someone can come up with a compelling reason not to.
Comment #8
dawehnerSymfony uses the stopwatch for various things, so if contrib would use some pieces (like the webdeveloper toolbar), they would have to require both, but sure this is not an important component at all.
Comment #9
sunAFAICS, we could easily make our Timer piggy-back on Stopwatch like this:
Alternatively, make the Timer class a singleton + manually instantiate the Stopwatch service once in a private constructor:
Comment #10
dawehnerOpened an issue to symfony as Timer::read() does not have a real replacement: https://github.com/symfony/symfony/issues/10175
Comment #11
catchIf this is worth doing (not sure it's worth it, how much code do we actually save?) we can add it without breaking BC, moving back to 8.x.
Comment #12
dawehner@catch
We really don't talk about a lot, tbh.
Comment #26
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #27
smustgrave commentedSince there's been no follow up to above in 3+ months going to close out. If still a valid task please re-open
Thanks all!