kanmel / 内存使用
此包的最新版本(2.0.1)没有可用的许可证信息。
一个基本的PHP类,用于跟踪内存使用情况
2.0.1
2017-09-28 13:42 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: 6.0.8
This package is not auto-updated.
Last update: 2024-09-15 02:16:48 UTC
README
一个简单的内存使用跟踪类,用于基准测试函数或代码执行内存消耗
#工作原理
- 开始内存跟踪
MemoryUsage::start(); - 标记一个位置为圈点(内存跟踪将在返回起始点和此圈点之间的差异后继续计数)
其中 $memoryUsage 是类的实例$memoryUsage = MemoryBench::lap();class MemoryUsage { protected $memory; protected $realMemory; protected $memoryPeak; protected $realMemoryPeak; } - 如果您想得到此圈点和上一个圈点之间的内存使用量,请将以下常量作为参数发送
$memoryUsage = MemoryBench::lap(MemoryBench::FROM_LAST_LAP); - 停止内存使用跟踪并从开始(起始点)获取内存使用量
$memoryUsage = MemoryBench::stop(); - 停止内存跟踪并从最后一个圈点获取内存使用量
$memoryUsage = MemoryBench::stop(MemoryBench::FROM_LAST_LAP); - 获取跟踪内存的历史记录
其中 $memoryUsages 是 MemoryUsage 类的数组$memoryUsages = MemoryBench::getHistory();