This whole discussion made me really curious - so you might want to 
check the attachments (access mixtest.php) for a very surprising result 
(please note mixed.php and pure.php are exactly the same size so this 
doesn't affect the test).

Bogdan

Marcelo Leitner wrote:

>On Mon, Jun 03, 2002 at 04:42:46AM +0300, Bogdan Stancescu wrote:
>  
>
>>I fell for this some time ago - but the trick is that
>>1. You don't do for ($i=0; $i<99999999999; $i++) { echo "Line $i<br>\n"; 
>>} in real life - you do stuff, call object methods, run queries, 
>>whatever, and in between those you have both html and php - and the 
>>remote machine waits for you to do all the "extra" stuff and _then_ 
>>waits for you to switch in and out of php for several times. I'm 
>>thinking about switching in and out of php in a "really-mixed" context - 
>>such as having blocks of html inside if() and while() blocks, stuff like 
>>that where you get to parse quite a number of php tags.
>>2. Your server doesn't only serve one client at a time - I'm surprised 
>>that you're starting with commercial sites and this piece of information 
>>isn't *always* present in your mind.
>>
>>However, as I said in my original mail, "there's an urban legend saying 
>>that [...] I don't know if that's true". So... I don't know if it 
>>actually slows things down or not.
>>
>>Bogdan
>>    
>>
>---end quoted text---
>
>I gave that example to be a create a huge final page with the less time
>as possible..
>You never do that loop, but what about logfiles analysing? You have tons of
>lines, probably splited by day, of all the accesses and whatever were done..
>I did a some time ago a database of the itens from a MUD game.. I allowed
>users to list the whole database, so they could read that and search for new
>items for them.. but each item had 6 lines displayed, without tables or
>anything, neither <li></li>.. only <br> and <p>..
>when it got about 400 items, my PIII-733 321MB ram got under it's knees to
>render that page.. it didn't have any fig or whatever that would need more
>time to render..
>I now that I'll not have a dedicated http server, but loosing microseconds
>at each page on a server that has one thousand accesses per day is nothing..
>And even if you're going to have that traffic you'll have better servers
>that will deal with that and will probably run more processes at a time, so
>a script that is coded "slowly" wouldn't break the other..
>What I don't do is
>...
>if ($a == $x) { ?>
>  <tr><td align=center><?echo $a?></td></tr>
><? } else { ?>
>  <tr><td align=right><?echo $a?></td></tr>
><? }
>...
>
>That's really ugly! :)
>
>[]'s
>  
>


<?
  if ($foo=="bar") { ?>
    <td>Bla-bla - testing</td>
    <?
    $bar=$foo;
    ?>
    <td><?=$bar ?></td><?
  }
?>
<?php
  if ($foo=="bar") {
    echo("<td>Bla-bla - testing</td>\n");
    $bar=$foo;
    echo("<td>$bar</td>\n");
  }
?>
<?php
  ini_set('max_execution_time', 600);
  function gettime() {
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
  }

  $t1=gettime();
  for ($i=0;$i!=10000;$i++) {
    include("mixed.php");
  }
  $t2=gettime();
  for ($i=0;$i!=10000;$i++) {
    include("pure.php");
  }
  $t3=gettime();

  echo(($t2-$t1)."s for mixed code;<br>\n");
  echo(($t3-$t2)."s for pure code.<br>\n");
  echo(round((($t3-$t2)/($t2-$t1)-1)*100,2)."% more time used for <b>PURE</b> 
code.<br>\n");
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to