How to Check Query Execution Time in PHP?
This tutorial shows you how to check query execution time in php. If you have a question about php query execution time then I will give a simple example with a solution. This example will help you php get query execution time. This tutorial will give you a simple example of how to get query execution time in php.
If you are looking for how to get sql query execution time in php then i will give you simple example for it. we will use microtime() function to calculate query execution time in php.
so, let's see the simple example code:
$startTime = microtime(true);
$connection = new mysqli("localhost","root","root","laravel10_crud");
$result = mysqli_query($connection, "SELECT * FROM users");
$endTime = microtime(true);
$executionTime = $endTime - $startTime;
echo "Query took " . $executionTime . " seconds to execute.";
Query took 0.0032229423522949 seconds to execute.
I hope it can help you...
We are Recommending you
- Laravel 10 Cron Job Task Scheduling Tutorial
- Ubuntu PHP bz2 Extension Install Commands Example
- How to Remove HTML Tags from String in Laravel?
- How to Use Enum in Laravel?
- PHP MySQL Column Sorting Example Tutorial
- How to Make Read More Link from String in PHP?
- How to Remove Duplicate Values from Array in PHP?
- How to Get File Name without Extension in PHP?
- How to Increase Upload File Size Limit PHP in Ubuntu?
- How to Check If String is URL or Not in PHP?
- How to Count Number of Files in a Directory in PHP?
- How to Find Day Name from Specific Date in PHP?
- How to Get Query Log in Laravel Eloquent?