简体   繁体   中英

running “exec()” under “windows+apache+php5.4” slower than command line

For some reason I need to run a C++ program in Windows + PHP . PHP code like:

$start = microtime();
exec("test.exe");
$end = microtime();

When I ran this php file as php test.php in command line, "test.exe" told its cost time is 11s. But I ran it with apache in browser like localhost/test.php , it finally output it costed 252s.

Is it any limit in apache when it fork a new process, or something else?


btw, "test.exe" is a program that I wrote to analyze data with windbg.

I use a few data to test its performance.

i. directly use "test.exe"

CDumpAnalyze::Analyze time cost[2.328000]

ii. call with php command line.

$start = microtime();
system("cd F:\\DumpPlatform\\bin\\server && test.exe --cfg=dump_config.ini --gameversion=10000");
//exec("dir");
$end = microtime();

echo $start."\n";
echo $end."\n";

CDumpAnalyze::Analyze time cost[2.982000]
0.09448800 1378104101
0.11078900 1378104104

iii. run with apache

CDumpAnalyze::Analyze time cost[63.158000] 
0.53862700 1378104642 
0.75394800 1378104705

Obviously there is no difference in time cost execution of your test.exe . So the difference is related to your web server and how it handles PHP scripts. Apache is a Thread Safe web server and there are many scheduling and other process tables exist in order to manage Thread safety on it. Besides, the time that your system costs for searching the path from Apache exe file to your test.exe file may play important role in exceeding the time cost in your case.

You can test your program on other web servers and post the results for exact comparison.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM