I found a very unpleasent thing in PHP.
From one point PHP performance decreases about 328 times (on my box).
I did following experiment:
## generated php script with python
>>> s = """<?php list($s_usec,$s_sec) = explode(" ",microtime()); ?>%s<?php list($e_usec,$e_sec) = explode(" ",microtime()); print (($e_sec+$e_usec)-($s_usec+$s_sec)); ?>""";
>>> open('test1.php','wb').write(s % ('.'*16895));
>>> open('test2.php','wb').write(s % ('.'*16896));
The first script test1.php gets time:
0.0001889467239379
The second script test2.php gets time:
0.062012076377869
It's about 328.19873817050217 times slower!!!
I have tested it in various ways and it's allways like this!!!
It means there is a certain page size in PHP from where performance will be tramatically decreased!!! One thing is certain it's in range 16800..17000 bytes.
Is anyone familiar with this problem?
How to increase this size?
Could it be done during compilation?
PHP magic performance decrease point!!!
Moderator: General Moderators
Whatever it is you're doing, it's less than clear.
Would it be possible to explain a couple of things.
1) Why are you generating the script from python?
2) What (and where) are these files that are being opened?
3) If these scripts are running at the behest of python, did you consider that python may also be part of the problem?
4) If this is a command line thing, why do you keep exiting and re-entering (<?php and ?>) php mode?
In short, there isn't a enough data as to exactly what you're doing before ANY conclusions can be arrived at.
Cheers,
BDKR
1) Why are you generating the script from python?
2) What (and where) are these files that are being opened?
3) If these scripts are running at the behest of python, did you consider that python may also be part of the problem?
4) If this is a command line thing, why do you keep exiting and re-entering (<?php and ?>) php mode?
In short, there isn't a enough data as to exactly what you're doing before ANY conclusions can be arrived at.
Cheers,
BDKR
why not using python (http://www.python.org), ist's the simplest and fastest way to do it (for me). In this case i generate two PHP scripts with python.BDKR wrote:Whatever it is you're doing, it's less than clear.Would it be possible to explain a couple of things.
1) Why are you generating the script from python?
2) What (and where) are these files that are being opened?
3) If these scripts are running at the behest of python, did you consider that python may also be part of the problem?
4) If this is a command line thing, why do you keep exiting and re-entering (<?php and ?>) php mode?
In short, there isn't a enough data as to exactly what you're doing before ANY conclusions can be arrived at.
Cheers,
BDKR
They are generated on python command line interactive interpretator (see my code) you can do it however you want to (C,PHP etc).
first PHP script "test1.php": should output 16895 dots ("."),
second PHP script "test2.php": should output 16896 dots (".")
Both scripts output execution delay of the script after dots as well.
My point is if there is a script which outputs 16895 dots (bytes) + delay string, then it is about 328 times faster than script which outputs only one byte more 16896 dost (bytes) + delay string.
It means there is a breakpoint, after some size performance decreases rapidly.
I call those scripts through Apache webserver using common Web browser (IE).
Well, I was hoping to see more code than what was provided, but no big deal. From what you said and described of what was going on, I produced some clearer tests. What I did was told one script (dots.php) to output 16895 dots. The script dots2.php does 16896. 1 more than dots.php. I created the script to run in one of two potential ways. 1 was to echo each dot individually. The other was to append the dot onto the end of a string then echo all of the dots out an once. Here are the results.
dots.php
with no delay delayed_out
1 1.11 0.29
2 1.13 0.26
3 1.03 0.29
4 1.07 0.27
5 0.99 0.27
dots2.php
with no delay delayed_out
1 0.95 0.30
2 0.94 0.30
3 1.06 0.28
4 0.96 0.28
5 1.09 0.30
In short, there is NO SIGNIFICANT DIFFERENCE with the addition of adding one more dot. The possible threshold you speak of is somewhere much higher than 16895 bytes.
Also, if the numbers above seem to suggest that it got faster with the addition of one dot, know that I also have a browser running, a web server, numerous other daemons in the backgound, wmcube, top, and Anjuta. In other words, the numbers don't mean much as a gauge of which is faster. That wasn't intended. Simply to see if there was a significant difference with the addition of that one dot. There isn't.
The problem must be an issue with how your tests are carried out. If you are testing a language, test it on it's own instead of executing it as a command or something from a different language. In this case, Python may be introducing more logic or overhead into the mix. Also, seperate tests. You are better off to run each test independend of another.
It's also interesting to note how much faster echoing out the entire 16895/6 dot/byte/whatever string than it is to each each at a time. I'll have to keep this in mind.
Anyways, 'ere be da kode!
And
Cheers,
BDKR (Terrence)
dots.php
with no delay delayed_out
1 1.11 0.29
2 1.13 0.26
3 1.03 0.29
4 1.07 0.27
5 0.99 0.27
dots2.php
with no delay delayed_out
1 0.95 0.30
2 0.94 0.30
3 1.06 0.28
4 0.96 0.28
5 1.09 0.30
In short, there is NO SIGNIFICANT DIFFERENCE with the addition of adding one more dot. The possible threshold you speak of is somewhere much higher than 16895 bytes.
Also, if the numbers above seem to suggest that it got faster with the addition of one dot, know that I also have a browser running, a web server, numerous other daemons in the backgound, wmcube, top, and Anjuta. In other words, the numbers don't mean much as a gauge of which is faster. That wasn't intended. Simply to see if there was a significant difference with the addition of that one dot. There isn't.
The problem must be an issue with how your tests are carried out. If you are testing a language, test it on it's own instead of executing it as a command or something from a different language. In this case, Python may be introducing more logic or overhead into the mix. Also, seperate tests. You are better off to run each test independend of another.
It's also interesting to note how much faster echoing out the entire 16895/6 dot/byte/whatever string than it is to each each at a time. I'll have to keep this in mind.
Anyways, 'ere be da kode!
Code: Select all
# dots.php
set_time_limit(0);
$time_start=0;
$string='';
$delay_out=0;
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$x=1;
$time_start=getmicrotime();
if($delay_out==0)
{
while($x<16895)
{ $string.='.'; ++$x; }
echo $string."\n";
}
else
{
while($x<16895)
{ echo '.'; ++$x; }
}
$time = (getmicrotime())-$time_start;
echo "To output $x number of dots took $time\n\n";Code: Select all
# dots2.php
set_time_limit(0);
$time_start=0;
$time_end=0;
$string='';
$delay_out=0;
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$x=1;
$time_start=getmicrotime();
if($delay_out==0)
{
while($x<16896)
{ $string.='.'; ++$x; }
echo $string."\n";
}
else
{
while($x<16896)
{ echo '.'; ++$x; }
}
$time = (getmicrotime())-$time_start;
echo "To output $x number of dots took $time.\n\n";BDKR (Terrence)