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

2001-05-16 Thread Ethan Schroeder

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 [EMAIL PROTECTED]
To: Merio, Quinn [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
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(/tdtd);
   print('a
  
href=mylink.php?linkId='.$row['projectId'].''.$row['projectName'].'/a
   ');
   print(/tdtd);
   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
tda
  
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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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

2001-05-16 Thread Ethan Schroeder

Sorry, I think that code got chopped off, try this:
?

 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: Ethan Schroeder [EMAIL PROTECTED]
To: Merio, Quinn [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, May 16, 2001 12:57 PM
Subject: Re: [PHP] RE: Processing time in PHP. better to use php tags inline
or pri nt(html);


 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 [EMAIL PROTECTED]
 To: Merio, Quinn [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 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(/tdtd);
print('a
   
 href=mylink.php?linkId='.$row['projectId'].''.$row['projectName'].'/a
');
print(/tdtd);
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
 tda
   
 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list

RE: [PHP] RE: Processing time in PHP. better to use php tags inline or pri nt(html);

2001-05-16 Thread Merio, Quinn


Thank you for your help, gentlemen, sorry about the re-post.

In case you were wondering about the results on that, the pages both
processed at almost identical times:

0.0023289918899536 - 1st hit
0.0022320411682129  - refresh 2
0.0017479658126831 -refresh 3

Cheers,
q.

Quinn Merio
www.vir2lalliance.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]