
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Compute Execution Time of a PHP Script
To compute the execution time of a PHP script, the code is as follows −
Example
<?php $start = microtime(true); $val=1; for($i = 1; $i <=1500; $i++) { $val++; } $end = microtime(true); $exec_time = ($end - $start); echo "The execution time of the PHP script is : ".$exec_time." sec"; ?>
Output
The execution time of the PHP script is : 1.69 sec
The ‘microtime’ function can be used to check the time taken by a PHP script to execute completely. When the code begins execution, the time is recorded, and once the code is completed, another timestamp is generated and the difference between the end and star time is the time taken by the script to complete its execution.
Advertisements