This article shows you how to check query execution time in PHP. If you have a question about php query execution time, 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, I will give you a simple example. We will use the microtime() function to calculate query execution time in PHP.
So, let's see the simple example code:
<?php $startTime = microtime(true); $connection = new mysqli("localhost","root","root","techvblogs"); $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.
Thank you for reading this article.
If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.