Benchmarking the execution time for a single function call by making a page and request it via b is a pretty flawed method. While it may show that a single aliased call to gettext() doesn't change the execution time of a script by much, it does not say anything about the relative times for execution of a specific function. You should call the function in a type loop and average over many executions. Here's a sample you can try: strlen.php: <? $a = 'blah'; while($i < 100000) { $b = strlen($a); $i++; } ?> gstrlen.php: <? $a = 'blah'; while($i < 100000) { $b = gstrlen($a); $i++; } function gstrlen($str) { return strlen($str); } ?> 22:54:00(george@wasabi)[~/src/php-4.0.6/ext]> time php /opt/apache/htdocs/strlen.php X-Powered-By: PHP/4.0.6 Content-type: text/html 0.840u 0.010s 0:00.85 100.0% 0+0k 0+0io 293pf+0w 22:54:17(george@wasabi)[~/src/php-4.0.6/ext]> time php /opt/apache/htdocs/gstrlen.php X-Powered-By: PHP/4.0.6 Content-type: text/html 1.950u 0.010s 0:01.95 100.5% 0+0k 0+0io 295pf+0w When done often enough, the difference between calling userland functions and builtins is _huge_. Substitute your favorite function in for strlen (I tried a bunch), you'll get similair results. Having to switch executor contexts evertime you call a userland function is really expensive. George On Saturday, September 8, 2001, at 08:07 PM, Cristopher Daniluk wrote: > I feel like you're getting a bit personal here, but I'll refrain from > doing > the same and simply provide numbers. This is a demonstration to prove > purely > the overhead of going into a userspace function that calls an internal > versus calling the internal directly. Obviously this isn't scientific, > but > that's not my goal. > > 3 scripts were created. First called _(""). Second defined a function as > follows: > > function b($str) { return gettext($str); } > > Third b("") instead of _("") - note the second one was created just to > try > and normalize out any deviance from parsing the new function. > > Apache Bench was run at 1000 queries to give enough performance to > illustrate a significant deviance. A concurrency of 10 and 100 were > used. > Each set was run 3 times and averages were taken to normalize outside > factors. Tests were run randomly at various times throughout the last > hour, > to reduce the effect of foreign elements. > > First Test (using _) > Concurrency 10: 50.24/50.23/57.43 = 52.63 > Concurrency 100: 44.58/46.59/44.53 = 46.23 > > Second Test (defining b) > Concurrency 10: 55.05/56.19/50.55 = 53.93 > Concurrency 100: 45.65/47.06/45.71 = 46.12 > > Third Test (using b) > Concurrency 10: 55.16/55.82/52.16 = 54.38 > Concurrency 100: 46.74/46.39/47.19 = 46.77 > > I really truly and with all my heart believe that if simply calling a > user > created function could drop performance by 25%, PHP would not be a > viable > language. Whether my results are accurate findings or not, Rasmus's > demonstration of a 26.3% performance decrease by CALLING A FUNCTION is > a lot > to swallow! > > Oh, and I'll refrain from making the muse that the latter test was > faster. > > Having the user make their own function may not be the right solution > for > this problem, but its phenomenally silly to argue that it would have a > large > performance impact! > > Regards, > > > Cristopher Daniluk > President & CEO > email: [EMAIL PROTECTED] > direct: 330/530-2373 > > Digital Services Network, Inc > Unleashing Your Potential > voice: 800/845-4822 > web: http://www.dsnet.net/ > > > -----Original Message----- > From: Chuck Hagenbuch [mailto:[EMAIL PROTECTED]] > Sent: Saturday, September 08, 2001 7:23 PM > To: [EMAIL PROTECTED] > Cc: 'PHP Developer List' > Subject: RE: [PHP-DEV] Woah > > > Quoting Cristopher Daniluk <[EMAIL PROTECTED]>: > >> Agreed, but is the speed loss really worth crying about? > > Obviously not to you, but I'm pretty sure you came down in the category > of > people who'd never used gettext. > >> It is negligible calling a userspace function versus an internal >> compared > to >> the greater work that the typical PHP script does. > > What authority do you have to make this statement? Rasmus posted > numbers. > Where > are yours? > > -chuck > > -- > Charles Hagenbuch, <[EMAIL PROTECTED]> > Some fallen angels have their good reasons. > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] >
BEGIN:VCARD VERSION:2.1 N:Daniluk;Cristopher FN:Cristopher Daniluk ORG:Digital Services Network, Inc.;Executive Management TITLE:President & CEO NOTE;ENCODING=QUOTED-PRINTABLE:=0D=0A TEL;WORK;VOICE:(330) 530-2373 TEL;WORK;VOICE:(800) 845-4822 TEL;CELL;VOICE:(330) 219-4819 TEL;WORK;FAX:(208) 723-6782 ADR;WORK;ENCODING=QUOTED-PRINTABLE:;President;89 West Marshall Avenue=0D=0ASuite A;McDonald;Ohio;44437;United S= tates of America LABEL;WORK;ENCODING=QUOTED-PRINTABLE:President=0D=0A89 West Marshall Avenue=0D=0ASuite A=0D=0AMcDonald, Ohio 4443= 7=0D=0AUnited States of America URL;WORK:http://www.dsnet.net/~cris EMAIL;PREF;INTERNET:[EMAIL PROTECTED] REV:20010528T230445Z END:VCARD
> -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED]