473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

testing php script performance

bilibytes
128 100+
hi there,

do anyone know a good php script performance tester? (free..)

thankyou

regards.
Mar 6 '09 #1
9 2317
I was thinking about how to speed test a php script, and I'm not sure.

I get the basics:

testing the first action
Expand|Select|Wrap|Line Numbers
  1. $i = 0;
  2. while($i < 10000){
  3. //do action 1
  4. }
  5. //return time
  6.  
testing the second action
Expand|Select|Wrap|Line Numbers
  1. $i = 0;
  2. while($i < 10000){
  3. //do action 2
  4. }
  5. //return time
  6.  
...hmmm...would getting the system time in microseconds at the beginning and end, and getting the difference work? sorry, but I just thought of that. I'll get back in a sec with confirmation or lack thereof.
Mar 6 '09 #2
Found the anser at php manual.

Here is the code for testing time in microseconds:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /**
  3.  * Simple function to replicate PHP 5 behaviour
  4.  */
  5. function microtime_float()
  6. {
  7.     list($usec, $sec) = explode(" ", microtime());
  8.     return ((float)$usec + (float)$sec);
  9. }
  10.  
  11. $time_start = microtime_float();
  12.  
  13. // Sleep for a while
  14. usleep(100);
  15.  
  16. $time_end = microtime_float();
  17. $time = $time_end - $time_start;
  18.  
  19. echo "Did nothing in $time seconds\n";
  20. ?>
  21.  
Mar 6 '09 #3
bilibytes
128 100+
so the usleep() would be replaced by the script to test?

Nice thanks!
Mar 6 '09 #5
TheServant
1,168 Expert 1GB
Yeah, you will need microtime() function, which returns a float anyway.
As much as the script above probably works, really all you need to do is have something like:
Expand|Select|Wrap|Line Numbers
  1. $timer = explode( ' ', microtime() );
  2. $start = $timer[1] + $timer[0];
  3.  
  4. ***Your Code***
  5.  
  6. $timer = explode( ' ', microtime() );
  7. echo( ($timer[1] + $timer[0])-$start );
  8.  
Mar 6 '09 #6
Thanks for the information. I had tried using date('u') initially, but that only returned all 0's.
Mar 6 '09 #7
TheServant
1,168 Expert 1GB
No worries. I did the same thing when I tried to make one last year before I was told about microtime().
Mar 6 '09 #8
Markus
6,050 Expert 4TB
Many PHP frameworks come with built-in benchmark testers. I especially like CodeIgniter's. http://codeigniter.com/user_guide/li...benchmark.html
Mar 6 '09 #9
Markus
6,050 Expert 4TB
Threads merged. Basically the same topic :)
Mar 6 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Tom Verbeure | last post by:
Hello All, so I'm now convinced that unit testing is really the way to go and I want to add it to an existing project. The first thing that I find out, is that, well, it's hard work. Harder than...
0
by: William Kossack | last post by:
We have developed a web based database app but now we have discovered the need to do functional testing. We don't need performance or benchmarking We don't want to spend too much time coding...
2
by: Curtis Justus | last post by:
Hi, I've been searching for solutions to two issues that are undoubtedly common to everybody. The first is how do my team and I adequately perform unit testing. The second is how can I measure...
4
by: Pablo Cedeno | last post by:
Hi all, I'm looking for a testing tool to test my web application made in aspx I started working with JMeter but i'm lost in this. I made the simpliest test, get an aspx page, but now i need to...
1
by: yoni | last post by:
Hi All, I have a complex C# application (winforms) that I am taking over. I do maintenance and add small features here and there. what I need is: 1. a tool that will help with testing. that is,...
5
by: =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post by:
Hi, I know that VS 2005 has a lot of testing features and already used them for doing web load testing. I am wondering if it is possible to load test a win forms application. I don't mean writing...
21
by: =?ISO-8859-1?Q?Fad=A5?= | last post by:
Hello guys, I want to do kinda of an A/B split testing on a website I run. I just created a new version but I need to keep both version running and see which one will perform better. First, I'm...
3
by: MacRules | last post by:
Found this testing tool, http://simpletest.sourceforge.net/ I am looking for PHP scripts which can be used as create many connections to a web server or MySQL back end for stress testing. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.