定制 takigawaakinori/phpunit-profiler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

takigawaakinori/phpunit-profiler

最新稳定版本:v0.2.0

Composer 安装命令:

composer require --dev takigawaakinori/phpunit-profiler

包简介

A PHPUnit extension that profiles and reports the slowest tests

README 文档

README

A PHPUnit extension that profiles test execution time and reports the slowest tests.

Supports PHPUnit 10, 11, 12, and 13.

日本語版はこちら: README.ja.md

Installation

composer require --dev takigawaakinori/phpunit-profiler

Usage

Add the extension to your phpunit.xml (or phpunit.xml.dist):

<extensions>
    <bootstrap class="TakigawaAkinori\PhpunitProfiler\TestProfilerExtension"/>
</extensions>

Configuration

You can customize the extension behavior by adding <parameter> elements:

<extensions>
    <bootstrap class="TakigawaAkinori\PhpunitProfiler\TestProfilerExtension">
        <parameter name="showTopN" value="false"/>
        <parameter name="topCount" value="50"/>
        <parameter name="showPareto" value="true"/>
        <parameter name="slowThreshold" value="1.0"/>
        <parameter name="jsonOutput" value=".test-profile-result.json"/>
    </bootstrap>
</extensions>
Parameter Type Default Description
showTopN bool true Show the top N slowest tests list. Set to false to hide
topCount int 20 Number of slowest tests to display
showPareto bool false Show Pareto analysis (top 20% of tests and their share of total execution time)
slowThreshold float (disabled) Show tests slower than the specified threshold in seconds
jsonOutput string (disabled) File path to export all test durations as JSON

Invalid Parameter Values

  • topCount: If the value is non-numeric or less than 1, it falls back to the default 20.
  • slowThreshold: If the value is non-numeric, threshold filtering is disabled.
  • showTopN / showPareto: These are string-based flags. Use true or false exactly.

Output Examples

After running your tests, you'll see output like:

Top 20 Slowest Tests:
--------------------------------------------------------------------------------
  1.  5.032s  Tests\Feature\ExampleTest::test_heavy_operation
  2.  3.210s  Tests\Feature\ExampleTest::test_api_call
  3.  0.523s  Tests\Unit\ExampleTest::test_calculation
--------------------------------------------------------------------------------

Requirements

  • PHP 8.1+
  • PHPUnit 10.0+

License

MIT

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固