Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread oorza2k5
I didn't think anonymous functions were ireleased until the 5.3 branch, which isn't near stable enough for production yet? On May 14, 2009 10:10pm, Andrew Muraco wrote: How about this for an idea: Write the code so that the switch returns the content of the case as a function, this way, y

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Andrew Muraco
How about this for an idea: Write the code so that the switch returns the content of the case as a function, this way, you can hopefully avoid having to do all those comparisons. (obviously you would then be able to use this anonymous function in place of the switch) Not sure if your code wou

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread oorza2k5
oops, just sent this to one guy =\ On May 14, 2009 3:52pm, oorza...@gmail.com wrote: Alright! answers :P Profiling the code, this script (which bottlenecks on the switch-case) is 82% of execution time __with__ APC. Of the script itself, ~45% of the execution time is this particular switch-

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread David Krings
Donald J. Organ IV wrote: If I remember correctly, if/else if/else statements are faster than Switch-Case. I heard that the other way around, but that doesn't mean anything. I googled switch versus if else and looked at various speed tests that people did. I found a few articles discussing PH

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread John Campbell
PHP should run ~1M switch tests per second on decent hardware. Either you are misinterpreting you profiling data, or running a switch statement a hell of a lot of time. I can't imagine any sort of if/else vs switch vs. jump table is going to make much of a difference. At best you will see a spee

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Anthony Wlodarski
Would this be a case where APC would decrease execution time of the script? -Anthony On Thu, May 14, 2009 at 5:07 PM, Elijah Insua wrote: > +1 for profiling (http://www.xdebug.org/) > > I nominate Caching as well. > > -- Elijah > > > On Thu, May 14, 2009 at 4:49 PM, Hans Zaunere wrote: > >> >

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Elijah Insua
+1 for profiling (http://www.xdebug.org/) I nominate Caching as well. -- Elijah On Thu, May 14, 2009 at 4:49 PM, Hans Zaunere wrote: > > Does anyone know how the PHP Interpreter pulls switch/case statements > > together? Does it emulate a C compiler and, for larger case sets, > > build a huge

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Hans Zaunere
> Does anyone know how the PHP Interpreter pulls switch/case statements > together? Does it emulate a C compiler and, for larger case sets, > build a huge if/else cascade? Does it do this always? Is there any way Since PHP isn't really compiled, there are some inefficiencies when compared with s

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Ben Sgro
Hello, How do you know the switch statement is your performance bottleneck? Did you profile the application? Care to share the code? - Ben Donald J. Organ IV wrote: If I remember correctly, if/else if/else statements are faster than Switch-Case. I would suggest converting them and see if y

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Donald J. Organ IV
If I remember correctly, if/else if/else statements are faster than Switch-Case. I would suggest converting them and see if you get a performance increase. - Original Message - From: "Eddie Drapkin" To: "NYPHP Talk" Sent: Thursday, May 14, 2009 2:12:15 PM GMT -05:00 US/Canada East

Re: [nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Anthony Wlodarski
How many cases are in this switch statement that is causing it to be slow? -Original Message- From: Eddie Drapkin Sent: Thursday, May 14, 2009 2:12 PM To: NYPHP Talk Subject: [nyphp-talk] Switch-Case v. if/else Does anyone know how the PHP Interpreter pulls switch/case statements toget

[nyphp-talk] Switch-Case v. if/else

2009-05-14 Thread Eddie Drapkin
Does anyone know how the PHP Interpreter pulls switch/case statements together? Does it emulate a C compiler and, for larger case sets, build a huge if/else cascade? Does it do this always? Is there any way to know when it builds a jump table (like a s/c is supposed to)? I've got a slow script (