PHP how to calculate function execution Time _php tutorial

Source: Internet
Author: User

How PHP calculates a function's execution time


This article mainly introduced the PHP computation function execution Time method, takes the MD5 function encryption run time as an example to analyze the PHP computation function running time the skill, needs the friend can refer to the next

This example describes how PHP calculates the execution time of a function. Share to everyone for your reference. Specific as follows:

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

The code is as follows:

$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
$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 is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/971951.html www.bkjia.com true http://www.bkjia.com/PHPjc/971951.html techarticle A method for calculating function execution time in PHP this article mainly introduces the method of PHP computational function execution time, taking the MD5 function encryption run time as an example to analyze the PHP calculation function running time of the technique ...

  • 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.