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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog