出于某种原因,我需要在Windows + PHP中运行C++程序。PHP代码如:
$start = microtime();
exec("test.exe");
$end = microtime();
当我php test.php
在命令行中运行这个 php 文件时,“test.exe”告诉它的成本时间是 11 秒。但我在浏览器中使用 apache 运行它localhost/test.php
,最终输出它花费了 252 秒。
当它派生一个新进程或其他东西时,它是否有任何限制?
顺便说一句,“test.exe”是我编写的一个程序,用于使用 windbg 分析数据。
我用一些数据来测试它的性能。
一世。直接使用“test.exe”
CDumpAnalyze::Analyze time cost[2.328000]
ii. 用php命令行调用。
$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. 用阿帕奇运行
CDumpAnalyze::Analyze time cost[63.158000]
0.53862700 1378104642
0.75394800 1378104705