SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I like anyones thoughts on if and why the following two case will differ greatly in execution speed. My options are:

    1/. Have a number of different scripts (approx 10) which are essentially the same, but with slight differences in relation to set variables with each script. All the scripts are called to execute when the page is opened.

    2/. Have 1 script which is executed x number of times (same number as individual scripts in above case), but each time the script is called, a passed variable, sets up the correct set variables (as case 1) via switch statements.

    Now, basically I'm asking as I don't exactly know the process by which the scripts are executed.

    In my head I'm thinking 1/. must be faster as the processor should be able to execute the 10 different scripts at approx the same time, but with case 2/. I'm thinking that that the processor may not be able to execute the same script a multiple of x number times (with different passed variables) at the same time, but must do each one sequentially.

    However, as unknowledgable as I am, I have no doubt that my thinking could well be flawed.

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AFAIK PHP isn't threaded i.e it can't support running lots of stuff at the same time. So I'm pretty sure the two things would run at the same speed as one way it would run 10 scripts one after the other, while the other way it would run the same script ten times over.

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That's an interesting point you raise, Skunk. I'm thinking that PHP is probably as threaded as the Web server using it, so if Apache is running with 20 threads handling 20 requests for PHP pages, those 20 threads are running code from the Apache PHP module. Boom: threaded PHP.

    This is just an informed guess, however. We'd need to consult someone with a knowledge of the inner workings of Apache and the PHP module.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd be very interested to find out the answer to this, as I wish to decide which of my two methods are best.

    Primarily I'm after speed, but if there is very little difference between the two methods, then the 'one fits all' script would be preferable for maintenance purposes.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i would say they are both the same speed




    Need a CGI Script ?? checkout CGI-Scripting

  6. #6
    SitePoint Zealot HotDog's Avatar
    Join Date
    May 2000
    Location
    Salt Lake City, UT
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The idea of having just one script file is very interesting to me. My question is how are you passing the variable to the script page. My guess would be include("variables.php?$var1"); . Is this right?

    I'd like to know since I may use it my self.
    Joe Eliason
    Just a dog learnin' PHP from cat.

  7. #7
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm passing various variables to various scripts in various ways:

    as a hidden field within forms,
    just declare a variable before including a file,
    pass it within the url,
    also do it the way you mention.

    My personnal favourite idea I can up with is using $PHP_SELF,

    You can use this so that you don't ever need to declare any variables at all - as long as you set up careful URL.

    $PHP_SELF - bust it into pieces, extract a piece that now forms your variable that then gets passed on.


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
  •