New Benchmark::start() and Benchmark::stop() method #45385
Unanswered
khalyomede
asked this question in
Ideas
Replies: 1 comment
-
Laravel now a days comes with spatie/ray, which has that option. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
With some collegues we wanted to know at which point our algorithm was taking a long time.
The business code is complex and uses Pipelines, each of the pipelines is suspected to take more or less time, and with
Benchmark
only supporting anonymous callback or array of callbacks it was impossible to split the pipeline easily.We end up using
Log::debug()
and I think it's a super opportunity to bring a new idea to help Benchmark to be useful in even more scenarios.Let's take a simplified example of the code I had to benchmark:
My proposal is to create 2 new methods to be able to flexibly call the Benchmark class anywhere on the code, in any order, by tagging the laps (or not), and getting the result anywhere else, offering a lot of freedom and limiting the code changes at the minimum when we need to only draw a time report of a complex algorithm.
And this is what could be written in a filter for example:
Other ideas
Benchmark::tags()
to know which tags exist and their state (started or stopped)Benchmark::dd()
could automatically stop all remaining pending tags by convenience (so the code above do not really need to callBenchmark::stopAll()
since dd would do it immediately)Beta Was this translation helpful? Give feedback.
All reactions