Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Benchmark Your Code in Laravel 9.32+

With the release of Laravel 9.32, the Benchmark helper was introduced.

The measure() static method takes in a Closure and outputs the execution time in milliseconds.

We can also pass an array of Closures:

We can also optionally specify how many iterations the Closures should run.
This will give us the average execution time:


Last but not least, theBenchmark Class has a dd() method.

Happy coding


Let me know what you think about this article through comments below, or on Twitter at @pelu_carol.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.



This post first appeared on Neutron Dev, please read the originial post: here

Share the post

How to Benchmark Your Code in Laravel 9.32+

×

Subscribe to Neutron Dev

Get updates delivered right to your inbox!

Thank you for your subscription

×