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 you get a performance increase.
----- Original Message -----
From: "Eddie Drapkin" <oorza...@gmail.com>
To: "NYPHP Talk" <talk@lists.nyphp.org>
Sent: Thursday, May 14, 2009 2:12:15 PM GMT -05:00 US/Canada Eastern
Subject: [nyphp-talk] Switch-Case v. if/else
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 (it's eating ~85% of execution time) that I
can't work around and one of the slower parts is a switch case (which
is slightly faster than manually building an if/else cascade) and was
wondering if anyone had any performance tips for cases like these.
_______________________________________________ New York PHP User
Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/show_participation.php
------------------------------------------------------------------------
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/show_participation.php