0

我必须测量 proc_open() 执行的进程的内存使用情况和执行时间。测量时间并不难,但我找不到任何方法来获取内存使用情况。(程序可以很快终止)

有什么方法可以获取由执行的进程的内存使用情况proc_open()吗?

由于某种原因,我的操作系统是 Windows ..

4

1 回答 1

1

@love-paper,利用descriptorspecproc_open 的参数将内存使用情况写入文件,然后您可以读取该文件。

父进程

$child_id = uniqid();
$descriptorspec = array(
   2 => array("file", "/tmp/$child_id", "a") // stderr is a file to write to
);
proc_open($cmd, $descriptorspec);

$memory_used = file_get_contents("/tmp/$child_id");

子进程

// at the end of the script
file_put_contents('php://stderr', memory_get_peak_usage(true));
于 2012-12-30T14:26:43.623 回答