Jump to content

PHP Optimization Techniques


Callister

Recommended Posts

Greetings everyone,

 

I'm in the process of optimizing code that is significantly old that was programmed in my lesser years.  I have learned a lot about better ways of doing things, however I have a question.

 

What is the best way to benchmark optimization progress? Is there a variable or any way I can configure to see if a script is in actuality more efficient [rather than just looking nicer]?

 

Thanks guys!

Call

Link to comment
https://forums.phpfreaks.com/topic/102178-php-optimization-techniques/
Share on other sites

<?php
$t1 = microtime(true);
  // method A
$t2 = microtime(true);
  // method B
$t3 = microtime(true);

printf ('Method A - %0.5f secs<br>', $t2-$t1);
printf ('Method B - %0.5f secs<br>', $t3-$t2);
?>

 

Or, use the Timer class from PEAR.  Works quite well.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.