hyperized/benchmark
Composer 安装命令:
composer require hyperized/benchmark
包简介
A small PHP Benchmark project
关键字:
README 文档
README
Comprehensive PHP server benchmarking utility. Tests your hosting environment across 15 benchmark modules and reports results in milliseconds.
Auto-detects CLI vs web and renders with the appropriate output mode:
- CLI — ANSI colors with Unicode box-drawing tables
- Web — styled HTML dashboard with responsive CSS grid layout
Each run saves a JSON report with a timestamp to reports/.
Benchmark Modules
| Category | Module | What it measures |
|---|---|---|
| Environment | PHP | Version, ini settings, memory limits, loaded extensions |
| I/O | Disk I/O | File creation across 8 block sizes (512B–64KB) |
| File Read | Sequential reads across file sizes (1KB–4MB) | |
| Network | DNS resolution and TCP connection latency | |
| Compute | CPU | Math functions, string operations, loops, conditionals |
| Memory | Allocation speed and peak memory per operation | |
| Regex | preg_match and preg_replace across 10 pattern types |
|
| JSON | Encode/decode with small, medium, and large payloads | |
| Serialization | serialize vs json_encode vs var_export (+ igbinary/msgpack if available) |
|
| Hashing | md5, sha1, sha256, sha512, xxh3, crc32, hmac-sha256, bcrypt, argon2id | |
| Encryption | AES-128/256-CBC/GCM, ChaCha20-Poly1305 encrypt and decrypt | |
| Compression | gzip, zlib, deflate (+ brotli/lzf if available) with compression ratios | |
| Runtime | Function Overhead | Named function, closure, first-class callable, static/instance method, arrow function |
| Type Casting | int/string/float/bool conversions | |
| Object Instantiation | stdClass, DateTime, SplStack, SplPriorityQueue, ArrayObject | |
| Database | MySQL | Query performance (requires ext-mysqli) |
All modules can be individually enabled/disabled and configured in config/config.yml.
Requirements
- PHP >= 8.4
- ext-mysqli (for MySQL benchmarks, optional)
Installation
composer create-project hyperized/benchmark cp config/config.yml.example config/config.yml
Adjust config/config.yml to your preferences. Set module toggles, cycle counts, MySQL credentials, and optionally override the output format.
Usage
CLI
php benchmark.php
Example output:
╔════════════════════════════════════════════════╗
║ PHP Benchmark Report ║
║ 2026-04-11 14:30:22 ║
╚════════════════════════════════════════════════╝
── PHP ───────────────────────────────────────────
PHP Version 8.5.4
Server CLI
Max Memory 128.00 MB
Max Upload 2.00 MB
Max Exec Time 0 seconds
Extensions 67 loaded
── Disk I/O ──────────────────────────────────────
Cycles: 100
ms (lower is better)
┌──────────┬──────────┬──────────┬──────────┐
│ 512.00 B │ 1.00 KB │ 2.00 KB │ 4.00 KB │ ...
├──────────┼──────────┼──────────┼──────────┤
│ 9.55ms │ 9.78ms │ 9.46ms │ 10.97ms │ ...
└──────────┴──────────┴──────────┴──────────┘
── Hashing ───────────────────────────────────────
Hash Functions (99999 cycles, ms, lower is better)
┌──────────┬──────────┬──────────┬──────────┬──────────┐
│ md5 │ sha1 │ sha256 │ sha512 │ xxh3 │ ...
├──────────┼──────────┼──────────┼──────────┼──────────┤
│ 143.00ms │ 155.71ms │ 387.45ms │ 288.95ms │ 16.35ms │ ...
└──────────┴──────────┴──────────┴──────────┴──────────┘
...
──────────────────────────────────────────────────
Total Duration 18.657s
Report saved reports/2026-04-11_143022.json
──────────────────────────────────────────────────
Web
php -S localhost:8000 benchmark.php
Open http://localhost:8000 for a styled HTML dashboard with cards for each module.
Remote
Install on the server via Composer and visit /benchmark.php in the browser.
Reports
JSON reports are saved to reports/ with timestamped filenames (e.g. 2026-04-11_143022.json). Disable via benchmark.output.report: false in config.
Configuration
All modules support enabled: true/false and configurable cycle counts:
benchmark: output: format: ~ # null = auto-detect, 'cli', or 'html' report: true # save JSON report to reports/ php: enabled: true disk: enabled: true cycles: 100 memory: enabled: true count: 9999 network: enabled: true cycles: 3 hosts: - google.com - cloudflare.com - github.com hashing: enabled: true hashCount: 99999 passwordCount: 10 # ... see config/config.yml.example for all options
Security
If deploying to a web server, ensure config.yml is not publicly accessible. For Apache with mod_rewrite:
<Files "config.yml"> deny from all </Files>
Development
composer analyse # Run PHPStan (level 8) composer cs-fix # Auto-fix code style (PER-CS2.0) composer cs-check # Check code style (dry run)
Contribution
I'm open to improvements and new benchmarks via pull requests.
Issues can be reported through Issues. Please include the full output of the script and your config file without the password.
License
MIT
hyperized/benchmark 适用场景与选型建议
hyperized/benchmark 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 610 次下载、GitHub Stars 达 14, 最近一次更新时间为 2018 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「mysql」 「modules」 「benchmark」 「disk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hyperized/benchmark 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hyperized/benchmark 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hyperized/benchmark 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is Paymorrow module for OXID eShop.
Dibi is Database Abstraction Library for PHP
Analysis module for finding problematical shop data.
yii2 swiper slider
An interactive tour through the TYPO3 backend.
PHP module for MySql database
统计信息
- 总下载量: 610
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-30