Home  >  Article  >  Backend Development  >  Development ideas for PHP test program running time

Development ideas for PHP test program running time

黄舟
黄舟Original
2017-08-21 15:15:111464browse

In order to test the running time of a broken program, I specially wrote such a class and added comments. It mainly uses several functions, the array list function list(), and the string is divided into the array function explode() to obtain the time. Stamp and microseconds microtime(), divide the microseconds into arrays and convert them into variables for processing, force the converted data to use floating point points to process, calculate the program duration, for everyone to learn and refer to, if you have any good suggestions Welcome to communicate.


Step 1: Download the php test program we need to use for this lesson and run it Time class: http://www.php.cn/xiazai/leiku/262

Step 2: After the download is completed, find the php class file, extract it to the local server, and create a new php document!

Step 3: We call this class in this new file and instantiate this class:

<?php
//举例
include_once "ceshi.php";//引入类文件
$time=new runTime();    //实例化
$time->star();
for ($i=1;$i<=1000;$i++){
   echo("a");
}
$time->stop();
echo $time->spent();
?>


##The running results are as shown below:

Development ideas for PHP test program running time

##Note:

We are here to introduce the idea and the simplest example. More friends can try it themselves.


The above is the detailed content of Development ideas for PHP test program running time. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn