【发布时间】:2012-12-30 21:26:40
【问题描述】:
是否可以在 PHP 中获得特定代码块的峰值内存使用量? memory_get_peak_usage() 函数似乎在整个过程执行中达到了峰值,直到函数调用为止,但这不是我想要获得的,因为其他代码块可能会扭曲该值。我试图隔离代码块本身,而不是整个过程。
例子:
// Block 1
for ($i = 0; $i < $iterations; ++$i) {
// some code
}
// Block 2
for ($i = 0; $i < $iterations; ++$i) {
// some different code
}
// Determine which of the two blocks used the most memory during their execution here
很遗憾,xdebug 目前不适合我。
【问题讨论】:
标签: php memory benchmarking