What are some common methods to measure the execution time of a sequence of commands, specifically related to database queries in PHP?

When working with database queries in PHP, it is important to measure the execution time of these queries to optimize performance. One common method to measure execution time is by using the microtime() function in PHP. By capturing the start and end times of the query execution, you can calculate the total time taken to execute the sequence of commands.

// Start time
$start_time = microtime(true);

// Your database query code here

// End time
$end_time = microtime(true);

// Calculate execution time
$execution_time = $end_time - $start_time;

echo "Query execution time: " . $execution_time . " seconds";