Link to home
Start Free TrialLog in
Avatar of hamlin11
hamlin11

asked on

Windows Server 2003 - PHP - shell_exec runs my Application 10 times slower than manually!

I have an EXE that I'm invoking through shell_exec() in PHP.

It takes 2.5 seconds to run whereas it only takes 0.25 seconds to run if I just double click the exe on the same server.

And this 2.5 seconds is not initialization or destruction - this is a custom timer I coded into the EXE that operates during runtime.

Note: The EXE runs as the internet guest account when invoked by PHP and as administrator when i double click
Note: The EXE contains logic to download a file from the internet (www.google.com actually for testing purposes)

Can I narrow the gap and make it run faster?

Thanks.

Avatar of hamlin11
hamlin11

ASKER

I added in a for loop that goes through a billion times and performs some arithmetic...

The "manual" run is 3.5 seconds... the "php" run is 6.0


SOLUTION
Avatar of Xyptilon2
Xyptilon2
Flag of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, it's approaching a 50% slowdown doing pure arithmetic. I was just hoping there was some way around it on a windows 2003 server.

Anymore thoughts?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The timer starts right before the simple arithmetic loop starts, and the timer stops as soon as that loop completes. I did this purposely so that we could ignore any initialization or deconstruction that must occur (e.g., loading/unloading libraries).

It does not download any data at this time - although my main program does. It's complex enough that it does not make sense to move it to PHP or ASP. I might make it a windows service when it is complete though.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I do not have another web server to test on, unfortunately
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
cxr, thanks for the reply. It's a dualcore processor on the server and there is approx. 0 database or php processing activity occurring. The only processing that I can conceive of that may be occuring is whatever loop the php processing logic must be in waiting on the exe invoked by shell_exec to exit.


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do I do that?
Have you even tried reading some docs?

Open a command shell, type 'php myscript.php' and hit return. If PHP is set up correctly on your machine, it will run the script directly, without any involvement from the web server. You'll need to cut your test script down to only do non-web related things (e.g. anything that relates to web-dependent super globals such as $_GET).
I've spent hours reading docs.

I'll give that a shot - thanks for the tip.
I'm sure at this point that it's not a PHP thing. It's a windows thing. There's lots of overhead when you create processes threads under a user who is not logged in via remote desktop or anything. Doesn't matter if it's an admin or a guest.