dongyu3967 2013-09-02 03:25
浏览 145

在“windows + apache + php5.4”下运行“exec()”比命令行慢

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."
";
echo $end."
";

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
  • 写回答

1条回答 默认 最新

  • donglian4879 2013-09-07 11:28
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line