洪水 / 组件性能监控
简单的性能信息收集器。
0.5.6
2019-05-31 21:15 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-08-29 04:20:04 UTC
README
Flood 组件性能监控
composer require flood/component-performancemonitor
许可协议
本项目是免费软件,根据两个许可证条款进行分发:CeCILL-C 和 GNU Lesser General Public License。您可以在 CeCILL-C (v1) 的条款下(适用于欧洲)或 GNU LGPL (v3) 的条款下(适用于世界其他地区)使用、修改和/或重新分发软件。
此文件和 LICENCE.* 文件在分发时需要保持不变。有关适用许可证的更多信息,请参阅:LICENCE.md
用法
预获取运行时数据
使用预获取的运行时数据,因此初始化脚本和逻辑也将被记录
<?php
$time = microtime(true);
$memory = memory_get_usage();
use \Flood\Component\PerformanceMonitor\Monitor;
// init codes, autoloading etc.
Monitor::i()->startProfile('profile-id', ['time' => $time, 'memory' => $memory]);
// main logic which should be recorded
Monitor::i()->endProfile('profile-id');
// maybe some other things
$result = Monitor::i()->getInformation('profile-id');
参见结果。
自动运行时数据
使用自动运行时数据,数据将在 startProfile() 内分配
<?php
use \Flood\Component\PerformanceMonitor\Monitor;
// init codes, autoloading etc.
Monitor::i()->startProfile('profile-id');
// main logic which should be recorded
Monitor::i()->endProfile('profile-id');
// maybe some other things
$result = Monitor::i()->getInformation('profile-id');
参见结果。
结果
方法 Monitor->getInformation('profile-id')
将返回一个包含索引 memory
(字节为单位)和 time
(秒为单位)的数组。
如果没有提供 profile-id,它将返回一个包含所有信息和 profile-id(作为第一个索引)的数组。
使用 Monitor->convertMemory($memory)
,可以将使用的内存从字节转换为 kb、mb 等等。
信息、支持和文档
有关 Flood 的更多信息、联系人和支持,请访问 flood.bemit.codes,文档位于 help.flood.bemit.codes。
作者
Michael Becker,michael@bemit.codes
v0.5.3