#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Php speed and efficiency


    Hi

    Ive got a php script that is currently running on a dedicated web server, i personally didnt make the script but purchased it as i dont know php very well.

    The script in question basically connects to a server using fsockopen, looks for a certain response and repeats the process "x amount of times per minute" carries. Once it recieves the response its looking for, another script is run.

    As its in competition with "other peoples scripts" looking to do the same thing, its mighty important to run efficiently and as quickly as possible.

    My question is, would php be the best language to run this script or something such as perl or c c++

    Also would an experienced php member, have a look at a part of the code in question and tell me if they think its efficient or could be made better please

    Thanks
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,743
    Rep Power
    9397
    Perl and PHP are both interpreted so there won't be much to gain there. C/C++ are certainly faster but it would take a lot more effort to do this there than in PHP.

    Is there a particular bottleneck? Something you can point out that's slow? Or just looking to improve it in general?
    And what's the code?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,864
    Rep Power
    368
    in order for someone to look at the code, you would need to take the first step and PROVIDE it here using [php ] tags..#

    if the code is in one file, you may be able to "measure" time between different pieces of code to see which section takes the longest and then try to reduce timing there
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Thanks for the replies guys,

    I dont really want to put the code out in the public, so tried to contact you via PM but unfortunately i cant as of yet.

    If you could pm me id really appreciate it.

    I was thinking of posting a job on somekind of freelancing site but thought id get the oppinion of some experts first who are not actually looking to take my money.
  8. #5
  9. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    501
    Rep Power
    127
    The socket communication piece alone I wouldn't worry too much about. I suspect your network connection would be a bottleneck before PHP would be for this; it's pretty simple stuff.

    The only exception to this would be if you're trying hit the socket as quickly as possible. C++ might be able to give you a higher rate of connections, but I'm not sure that'd be advisable behavior to begin with. You'd probably *want* that rate slowed down to once per second, or once every 10 seconds, etc. And once you have an explicit delay, any slowness PHP would give you doesn't matter much.

    As for the script that gets kicked off when you get your certain response, that might be another story. I couldn't even guess at that without knowing what it's at least trying to do.
    LinkedIn: Dave Mittner

IMN logo majestic logo threadwatch logo seochat tools logo