|How to measure the speed of executing PHP Scripts
|Page 1 of 1|
|Author:||hocbongro [ Tue Aug 21, 2018 8:53 am ]|
|Post subject:||How to measure the speed of executing PHP Scripts|
If you choose PHP as your programming language to study and develop your projects later on, then you will probably need to figure out how fast your code runs. long. Because execution speed holds a very important role for large projects. Simply put, if you are programming for a website with "hoc bong ro" a large amount of traffic and the speed at which PHP code executes, then your site will probably be at risk and no one will want to visit the site. you too.
Measuring the speed of code execution in PHP is really simple and easy. There are many ways to do this, but the way you share it in this article is very useful and easy to understand. I myself often use this method to check my own code.
At the beginning of the PHP code that you need to test, just insert the following script:
$ s = microtime (true);
And at the bottom of the code to test the speed, you insert this script:
$ e = microtime (true);
echo round ($ e - $ s, 2). "Sec";
So you can measure the speed of your code execution in the code above, you can remove the second parameter in the round () function if you want. However, if you get results like '0 Sec' then increase the value in this parameter until you get the result you want.
There is one more thing that you should note when increasing the value in the second parameter in the round () function. That is when you increase the value to about 5 - 6 then you will probably get results like 3.5E-5. With this result, it can make many of you feel confused if you are not familiar with mathematical characters. And if 3.5E-5 is converted, then the value is equal to 0.000035. You can learn more about these mathematical symbols online so that you can get the correct answer for your results.
I hope, with this simple tricks will help you have more knowledge as well as experience in programming with PHP language. And I hope you can share this article for your friends, as well as you have other ways to measure the speed of PHP code implementation should be shared for yourself and other friends in the form of comments after write this.
Good luck !
|Page 1 of 1||All times are UTC|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group