September 9th, 2013, 05:16 AM
Php speed and efficiency
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
September 9th, 2013, 05:27 AM
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?
September 9th, 2013, 06:08 AM
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
September 13th, 2013, 05:53 AM
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.
September 13th, 2013, 11:14 AM
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.