Re: deep investigation of PHP_Callback

From: Date: Sun, 06 May 2007 15:55:24 +0000
Subject: Re: deep investigation of PHP_Callback
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-46643@lists.php.net to get a copy of this message
Howdy all... Bertrand Mansion wrote:
Le 6 mai 07 à 02:22, Travis Swicegood a écrit :
Using this assumption as the base, I put together a quick script to generate PHP files to benchmark against (script is available at http://plumb.domain51.com/pear/gen.phps). Using the following ab command I got these results: ab -c 100 -t 60 http://localhost/path/to/[proc|pear].php > proc|pear.ab
proc.php:Requests per second:    165.57 [#/sec] (mean)
pear.php:Requests per second:    111.89 [#/sec] (mean)
Using this as the code to benchmark against, PHP_Callback (pear) code is roughly 33% slower, not 320% - 350%. It is still a sizable amount and one to be taken into account when optimizing code, but given the other areas where code is almost certainly not optimized within any given project, this would probably be one of the last areas you were start trying to squeeze the milliseconds out of the code.
Here are my results for your scripts on a MacBookPro 2.33 Ghz Core Duo:
Proc: Requests per second:    3127.15 [#/sec] (mean)
Pear: Requests per second:    585.43 [#/sec] (mean)
That's 5 times slower. It is, I think, a lot closer to truth than your own results... For other tests, I am in line with Greg's results.
This borders on moving off-topic, but if you'll indulge me... That's actually a really interesting result. Greg, do you happen to run a Mac as well? I'm wondering what the difference between the Mac (maybe it's at the BSD level) and Linux is. I just re-ran the tests in a much more accurate server environment (Intel 4/HT 3.0Ghz with 2Gb of RAM versus my Intel 4 2.0Ghz with .5Gb) and got almost identical results to my first test:
pear.php:Requests per second:    202.67 [#/sec] (mean)
proc.php:Requests per second:    336.94 [#/sec] (mean)
The procedural did start to pull away a bit more, but not by much. I wonder if it's the dual core architecture or the OSes memory management. I've updated the gen.php script to include memory_get_peak_usage() as the last line. The numbers on that box show 231k vs 300k for procedural versus class. If you're interested, I'd love to hear the memory numbers on Mac vs. Linux. -Travis

« previous php.pear.dev (#46643) next »