  | |  | AW: [Flashcoders] Switch/Case vs If/else | AW: [Flashcoders] Switch/Case vs If/else
2004-02-11 - By FS Thomas
Back
FODOR wrote:
> Not with else if, only with else. To do what you say you have to write it :
> If(){
> }else{
> if(){}
> }
>
> Or put a break; when the if statement is true.
I tried Fordor 's suggestion, and re-wrote the if() structure only using
else() rather than else if(). The results? Strikingly similar. If()
still wins.
Times run: 100
Average if() time : 50
switch() time: 30
-- ---- ---- ---- ---- ----
Times run: 100
Average if() time : 50
switch() time: 30
-- ---- ---- ---- ---- ----
Times run: 100
Average if() time : 40
switch() time: 60
-- ---- ---- ---- ---- ----
Times run: 100
Average if() time : 30
switch() time: 60
-- ---- ---- ---- ---- ----
...
Results : if(): 204ms VS switch():228ms
-f.
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:103823
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |