vega/memory-stat
Composer 安装命令:
composer require vega/memory-stat
包简介
Simple class which can be used to collect the PHP script memory usage information and to print all information.
README 文档
README
#Memory Stat# This is a simple which can be used to collect the PHP script memory usage information and to print all information. If you want to use it example on web page or command line script. Or even do another function for web pages and another for command line scripts. Usage
Install the latest version with composer require vegagame/memory-stat
<?php use vegagame\MemoryStat; // Create new MemoryStat instance $m = new MemoryStat(true); // Example array $a = array(); $b = array(); $c = array(); // Fill array with for ($i = 0; $i < 10000; $i++) { $a[$i] = uniqid(); } // add first checkpoint $m->addCheckpoint('first checkpoint'); // get current memory limit from ini_get('memory_limit') echo 'Memory limit raw: '.$m->getMemoryLimitRaw().PHP_EOL; // 536870912 // get current memory limit formatted from ini_get('memory_limit') echo 'Memory limit: '.$m->getMemoryLimit().PHP_EOL; // 512M // get current memory usage echo 'Current raw: '.$m->getCurrentRaw().PHP_EOL; // 1835008 // get current memory usage formatted echo 'Current: '.$m->getCurrent().PHP_EOL; // 1.75M // Fill array for ($i = 0; $i < 30000; $i++) { $b[$i] = uniqid(); } // get peak Raw echo 'Peak raw: '.$m->getPeakRaw().PHP_EOL; // 6815744 // get peak usage formatted echo 'Peak: '.$m->getPeak().PHP_EOL; // 6.5M // add new checkpoint $m->addCheckpoint('second checkpoint'); // Fill array for ($i = 0; $i < 50000; $i++) { $c[$i] = uniqid(); } // get current raw information print_r($m->getInfoRaw()); /** * Array * ( * [time] => 1415461726 * [time_format] => 2014-11-08 16:48:46 * [total] => 536870912 * [current] => 15466496 * [increase_from_last_percent] => 55.93 * [total_percent] => 2.88 * * ) */ // get info formatted echo 'Get current information: '.$m->getInfo().PHP_EOL; // Memory Stat [2014-11-08 16:48:46] | Usage: 14.75M (2.88%) echo 'Get current information verbose : '.$m->getInfo(true).PHP_EOL; // Memory Stat [2014-11-08 16:48:46] | Memory Usage: 14.75M (2.88%) | Memory Peak: 14.75M | Memory Total: 512M | Increase from last checkpoint 55.93% echo 'Total information: '.PHP_EOL; echo $m->getTotal(true); // verbose version /** * Memory Stat [2014-11-08 16:48:40] | Info: Memory Stat Start | Memory Usage: 256K (0.05%) | Memory Peak: 14.75M | Memory Total: 512M | Increase from last checkpoint 0% * Memory Stat [2014-11-08 16:48:41] | Info: first checkpoint | Memory Usage: 1.75M (0.34%) | Memory Peak: 14.75M | Memory Total: 512M | Increase from last checkpoint 85.71% * Memory Stat [2014-11-08 16:48:43] | Info: second checkpoint | Memory Usage: 6.5M (1.27%) | Memory Peak: 14.75M | Memory Total: 512M | Increase from last checkpoint 73.08% * Memory Stat [2014-11-08 16:48:46] | Info: Memory Stat End | Memory Usage: 14.75M (2.88%) | Memory Peak: 14.75M | Memory Total: 512M | Increase from last checkpoint 55.93% */ // return all checkpoint array print_r($m->getTotalRaw());
Copyright
Copyright (c) 2014 Denis Casanuova. See LICENSE for details.
vega/memory-stat 适用场景与选型建议
vega/memory-stat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.69k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「memory」 「memory usage」 「memory limit」 「memory peak」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vega/memory-stat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vega/memory-stat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vega/memory-stat 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Rapid pagination without using OFFSET
repository php library
Limit number of records that can be added to a SilverStripe GridField
PHP PDO Mysql select statement iterator implemented as multiple queries using LIMIT clauses
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
Magento 2 Discount Amount Limiter
统计信息
- 总下载量: 1.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-08