CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, Fhalcon, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Sat Jul 24, 2021 11:50 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: How to measure the speed of executing PHP Scripts
PostPosted: Tue Aug 21, 2018 8:53 am 

Joined: Tue Aug 21, 2018 8:46 am
Posts: 1
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 !

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 10 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2016 phpBB Group