note 105751 deleted from function.printf by danbrown
| From: | danbrown@php.net | Date: | Tue, 13 Sep 2011 14:24:05 +0000 |
| Subject: | note 105751 deleted from function.printf by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183140@lists.php.net to get a copy of this message | ||
Note Submitter: admin at torntech dot com
----
Normal concatenation is slightly faster than printf for simple combination of strings.
Example:
<?php
$var = "World";
print("Hello $var"); //Faster
printf("Hello %s", $var); //Slower
?>
Tested against 6 for..loops of 100x loops (3 of each) using PHP 5.3.8.
The very first print or echo in the script is always the slowest regardless of type, I assume due to
the application propagating functionality into memory.
Regardless, printf was always ~30 µs slower than normal concatenation in all 3 loop tests.