How PHP calculates the execution time of a function

Source: Internet
Author: User
Tags md5

This article mainly introduced the PHP computation function execution Time method, takes the MD5 function to encrypt the running time as an example to analyze the PHP computation function running time skill, the need friend may refer to the next

The example in this article describes the way in which PHP calculates function execution time. Share to everyone for your reference. as follows:

We can record the start and end times separately before and after the program, and the two time difference is the program execution times.

The code is as follows: <?php
$long _str = "This are a test to" so much time MD5 function takes to execute over this string ";
Start timing from
$start = Microtime (true);
function to test
$MD 5 = MD5 ($long _str);
$elapsed = Microtime (True)-$start;
echo "That took $elapsed SECONDS.N";
?>

The results of the operation are as follows:

That took 7.1525573730469E-6 seconds.

I hope this article will help you with your PHP program design.

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.