#40165 [Fbk->Bgs]: define() cost
| From: | tony2001@php.net | Date: | Fri, 19 Jan 2007 14:19:12 +0000 |
| Subject: | #40165 [Fbk->Bgs]: define() cost | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107765@lists.php.net to get a copy of this message | ||
ID: 40165
Updated by: tony2001@php.net
Reported By: gacek at intertele dot pl
-Status: Feedback
+Status: Bogus
Bug Type: Performance problem
Operating System: Linux FC4 x86_64
PHP Version: 5.2.0
New Comment:
count(array()) just returns ht->nNumOfElements, this is probably the
most simple function in PHP.
define() copies (malloc() + memcpy()) the value, duplicates the name
(malloc() + memcpy() again) and adds it to the hash of constants (which
might involve realloc() etc.).
So it's kinda expected that a function which does almost nothing is a
bit faster, like 7x or 6x, which are the numbers I can see myself.
Previous Comments:
------------------------------------------------------------------------
[2007-01-19 11:33:51] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2007-01-19 11:33:22] gacek at intertele dot pl
This is sample of "pprofp -u" output from fairly complex app:
Total Elapsed Time = 2.47
Total System Time = 0.35
Total User Time = 1.36
Real User System secs/ cumm
%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call
Memory Usage Name
--------------------------------------------------------------------------------------
13.9 0.24 0.24 0.19 0.19 0.04 0.04 850 0.0002 0.0002
0 define
12.1 0.27 0.27 0.16 0.16 0.05 0.05 18653 0.0000 0.0000
0 count
10.9 0.15 0.15 0.15 0.15 0.04 0.04 11652 0.0000 0.0000
0 is_array
9.1 0.26 0.26 0.12 0.12 0.03 0.03 15489 0.0000 0.0000
0 each
6.2 0.18 0.18 0.08 0.08 0.02 0.02 9012 0.0000 0.0000 0
array_shift
4.1 0.08 0.08 0.06 0.06 0.02 0.02 5402 0.0000 0.0000 0
ereg_replace
4.1 0.04 0.04 0.06 0.06 0.01 0.01 655 0.0001 0.0001 0
mysql_fetch_array
3.8 0.07 0.07 0.05 0.05 0.01 0.01 5277 0.0000 0.0000 0
urlencode
2.9 0.04 0.04 0.04 0.04 0.00 0.00 2520 0.0000 0.0000 0
func_num_args
2.9 0.05 0.05 0.04 0.04 0.00 0.00 1465 0.0000 0.0000 0
sprintf
------------------------------------------------------------------------
[2007-01-19 11:28:44] gacek at intertele dot pl
Description:
------------
When playing with apd profiler, I have noticed huge cost of define()
call. It's over 20x the cost of average count() call.
Might it be apd inaccuracy or define() specifics, or define()
implementation is heavily broken?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40165&edit=1