Results 1 to 4 of 4

Thread: Code performance: which is faster ?

  1. #1
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Code performance: which is faster ?

    Just asking for a second opinion on my theory.

    Say I have 5 cases in a switch statement. And for each case I have a block of 1kb of code. Now if all this code was contained in this page I'd have a 5kb sized php document.

    Now say I put my 1kb cases in separate pages and include them via include ()
    This would make my main page ~ 1-2 kb. Would this make my page load faster?
    The reasoning is 1. the page is smaller and 2. The 4 cases that aren't executed wont include the block of text at all ... ??

    What do you guys think ?

    Oh yeah and while I'm posting, if php is so good, and free, and powerful, why use any other server side? Obviously for the sake of choice/variety or something, but does any other code have any major advantages ?

    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm not sure that you can include/not include pages dynamically using PHP. I think not. If not, your question is moot.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    just tested with XAMPP local host : php 5.1.1

    It works!

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    This would make my main page ~ 1-2 kb. Would this make my page load faster?
    There wouldn't be an improvement, since the joy of parsing as you go is that code that's never reached is never parsed, so it doesn't have a performance hit.
    Oh yeah and while I'm posting, if php is so good, and free, and powerful, why use any other server side? Obviously for the sake of choice/variety or something, but does any other code have any major advantages ?
    Because PHP as a language is rather poor It has little in the way of standardisation of function names (for example, mysql_select_db and fsockopen); it lacks the object-orientation of other languages (although in fairness to it, it does seem to be trying now); and it's slow. People complain about the speed of Java, but according to several benchmarks, PHP is far slower.
    Also, PHP is interpreted as it executes, every time. Something like JSP, by comparison, is compiled once when it's first accessed, then runs from bytecode. This is a lot more efficient for all subsequent calls.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •