Re: RE: Processing time in PHP. better to use php tags inline or pri nt("<html>");

From: Date: Wed, 16 May 2001 19:57:22 +0000
Subject: Re: RE: Processing time in PHP. better to use php tags inline or pri nt("<html>");
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53078@lists.php.net to get a copy of this message
The following code is not mine, so I take no credit for it. It seems to work fine for me, though: <? class c_Timer { var $t_start = 0; var $t_stop = 0; var $t_elapsed = 0; function start() { $this->t_start = microtime(); } function stop() { $this->t_stop = microtime(); } function elapsed() { if ($this->t_elapsed) { return $this->t_elapsed; } else { $start_u = substr($this->t_start,0,10); $start_s = substr($this->t_start,11,10); $stop_u = substr($this->t_stop,0,10); $stop_s = substr($this->t_stop,11,10); $start_total = doubleval($start_u) + $start_s; $stop_total = doubleval($stop_u) + $stop_s$ $this->t_elapsed = $stop_total - $start_total; return $this->t_elapsed; } } }; /* Here's an example usage: $timer = new c_Timer; $timer->start(); echo "<hr>"; $timer->stop(); echo $timer->elapsed(); */ ?> ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Merio, Quinn" <Quinn.Merio@ideamachine.com> Cc: <php-general@lists.php.net> Sent: Wednesday, May 16, 2001 9:47 AM Subject: Re: [PHP] RE: Processing time in PHP. better to use php tags inline or pri nt("<html>"); > Why don't you just benchmark both? > > On Wed, 16 May 2001, Merio, Quinn wrote: > > Sorry to nag, i hadnt recieved any responses on this post yet.. would like > > to re-request.. I wanted to know if there is drawbacks or benefits to using > > the php alternate syntax? > > > > > 1.) Is it possible (and if so, how do i) get the time it took to process > > > the page (seconds or milliseconds)? > > > > > > 2.) This is where the first q arose from: I am trying to ascertain which > > > is faster, outputting a query using the print function or using the > > > alternate syntax. I know that in ASP, jumping in and out of the asp code > > > slows down the page processing. > > > > > > Here is the two ways i am outputting my recordset: > > > > > > 1.----- from within the php code ----- > > > > > > <table cellpadding="4" cellspacing="4" > > > border="2"> > > > <?php > > > > > > for ($i = 1; $i <= $nr; $i++){ > > > $row = mysql_fetch_assoc ($rs); > > > > > > print("<tr>"); > > > print("<td>"); > > > print($row['projectId']); > > > print("</td><td>"); > > > print('<a > > > href="mylink.php?linkId='.$row['projectId'].'">'.$row['projectName'].'</a> > > > '); > > > print("</td><td>"); > > > print($row['projectStatus']); > > > print("</tr>"); > > > > > > } // End Loop rows > > > > > > ?> > > > > > > </table> > > > > > > > > > 2.------------ inline code with the html -------------- > > > > > > <table cellpadding="4" cellspacing="4" > > > border="2"> > > > <? for ($i = 1; $i <= $nr; $i++): ?> > > > <? $row = mysql_fetch_assoc ($rs);?> > > > <tr> > > > <td><?print($row['projectId']);?></td> > > > <td><a > > > href="myfile?blah=<?=$row['projectId']?>"><?print($row['projectName']);?>< > > > /a></td> > > > <td><?print($row['projectStatus']);?></td> > > > </tr> > > > <? endfor; ?> > > > </table> > > > > > > Any thoughts from the experts? I love being able to mix html and php tags, > > > but am worried about efficiency. > > > > > > TIA, > > > > > > Quinn Merio > > > Vir2lAlliance Inc. > > > www.vir2lalliance.com > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#53078) next »