geocurly/easy-benchmark 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geocurly/easy-benchmark

Composer 安装命令:

composer require geocurly/easy-benchmark

包简介

Simple benchmark wrapper for your php code

README 文档

README

There is the simple benchmark library for your php code.

⚠️ This library is applicable only for fast estimate performance of your decition. If you want to find a complete solution, look at Xdebug, XHProf and etc.

Examples

  1. Compare array merge functions performance
<?php

use EasyBenchmark\EasyBenchmark;

require __DIR__. "/../vendor/autoload.php";

$arrays = [];
for ($i = 1; $i <= 100; $i++) {
    $arrays[] = range(0, 1000);
}

$test = [
    "sequence merge" => function () use($arrays) {
        $arr = [];
        foreach ($arrays as $array) {
            $arr = array_merge($arr, $array);
        }
    },
    "merge unpacked array" => function () use($arrays) {
        array_merge(...$arrays);
    }
];

foreach (EasyBenchmark::run($test, 100) as $result) {
    echo (string) $result . "\n";
}

/*
 * Output: 
 * Name: sequence merge. Iteration 100. Execution time 8.31734 ms
 * Name: merge unpacked array. Iteration 100. Execution time 0.17974 ms.
 */
  1. Check function memory usage
<?php

use EasyBenchmark\EasyBenchmark;
use EasyBenchmark\Result;

require __DIR__. "/../vendor/autoload.php";

$storage = new class {
    private array $storage = [];
    public function push($value): void
    {
        $this->storage[] = $value;
    }
};

$testFunctions = [
    "testMemoryUsage" => static function (Result $result) use($storage) {
        $storage->push(random_bytes(random_int(100000, 200000)));
        $result->setMemory(memory_get_usage());
    }
];

/*
 * There is we set third input argument as "false" to get every iteration result
 */
foreach (EasyBenchmark::run($testFunctions, 10, false) as $result) {
    echo "Iteration: {$result->getIter()}. Memory: {$result->humanReadableMemory()} \n";
}


/*
 * Output:
 * Iteration: 1. Memory: 1,04 МБ
 * Iteration: 2. Memory: 1,20 МБ
 * Iteration: 3. Memory: 1,35 МБ
 * Iteration: 4. Memory: 1,46 МБ
 * Iteration: 5. Memory: 1,63 МБ
 * Iteration: 6. Memory: 1,79 МБ
 * Iteration: 7. Memory: 1,90 МБ
 * Iteration: 8. Memory: 2,07 МБ
 * Iteration: 9. Memory: 2,18 МБ
 * Iteration: 10. Memory: 2,35 МБ
 */

geocurly/easy-benchmark 适用场景与选型建议

geocurly/easy-benchmark 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.96k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 geocurly/easy-benchmark 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 geocurly/easy-benchmark 我们能提供哪些服务?
定制开发 / 二次开发

基于 geocurly/easy-benchmark 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-29