note 12862 deleted from language.references.pass by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 01:24:58 +0000 |
| Subject: | note 12862 deleted from language.references.pass by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57344@lists.php.net to get a copy of this message | ||
Note Submitter: ulysses@mail.NOSPAM.fitan.com.tw
----
It seems that passing by reference is slower than ordinary function call. I created an text file
(about 10k) and compare the performance:
<?
function foo1(&$str) { /* do something here */ }
function foo2($str) { /* do something here */ }
$inputBuffer = "";
$fp = fopen("foo.txt","r")
$inputBuffer = fread($fp,filesize("foo.txt");
foo1($inputBuffer);
foo2($inputBuffer);
?>
I found that calling foo1() is slower than foo2() by about 5% (measured using the code listed in
microtime().