Php: how to calculate the function execution time. php: how to calculate the function execution time

Source: Internet
Author: User
Php calculates the function execution time. Php calculates the execution time of functions. This document describes how php calculates the execution time of functions. Share it with you for your reference. Details: we can use php to calculate the function execution time and php to calculate the function execution time.

This example describes how to calculate the function execution time in php. Share it with you for your reference. The details are as follows:

We can record the start time and end time respectively before and after the program. The two time differences are the execution time of the program.
The code is as follows: <? Php
$ Long_str = "this is a test to see how much time md5 function takes to execute over this string ";
// Start timing from here
$ Start = microtime (true );
// Function to test
$ Md5 = md5 ($ long_str );
$ Elapsed = microtime (true)-$ start;
Echo "That took $ elapsed seconds. \ n ";
?>

The running result is as follows:

That took 7.1525573730469E-6 seconds.

I hope this article will help you with php programming.

Examples in this article describes how to calculate the function execution time in php. Share it with you for your reference. Details: we can...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.