Use echo instead of print in themes for speed?
Hat tip to RobLoach who noted this in the #drupal IRC channel-- if we want to squeeze hundredths of a millisecond more out of our Drupal modules and themes, we should use echo instead of print for getting the data to the screen.
UPDATE: The PHP developers don't recommend switching from print to echo for speed reasons, suggesting that the difference can be dependent on the setup of your environment.
Random more useful PHP code speed improvements:
Best to not rely on include_path:
Good: include("./file.php"); // Looks for the file in the current working directory.
Bad: include("file.php"); // Searches every directory in include_path.
Using include_once and require_once is also much slower than include and require.
Use an opcode cache.
References
http://www.learnphponline.com/php-basics/php-echo-vs-print
http://ilia.ws/files/phptek2007_performance.pdf
http://ilia.ws/files/phpquebec_2009.pdf
Comments
Post new comment