承接 nexusphp/tachycardia 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nexusphp/tachycardia

Composer 安装命令:

composer require nexusphp/tachycardia

包简介

Detects slow running tests in your PHPUnit-driven test suites.

README 文档

README

PHP version build Coverage Status PHPStan Latest Stable Version License Total Downloads

Tachycardia is a PHPUnit extension that detects and reports slow running tests and prints them right in your console. It can also optionally inline annotate the specific tests in the files during pull requests.

NOTE: Tachycardia will only detect the slow tests in your test suites but will offer no explanation as to why these identified are slow. You should use a dedicated profiler for these instead.

$ vendor/bin/phpunit
PHPUnit 10.5.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.1 with Xdebug 3.3.1
Configuration: /home/runner/work/tachycardia/tachycardia/phpunit.xml.dist
Random Seed:   1698146158

................................................................. 65 / 96 ( 67%)
...............................                                   96 / 96 (100%)

Nexus\PHPUnit\Tachycardia\TachycardiaExtension identified this sole slow test:
⚠  Took 1.3374s from 1.0000s limit to run Nexus\\PHPUnit\\Tachycardia\\Tests\\Renderer\\GithubRendererTest::testRendererWorksProperly

Slow tests: Time: 00:00:01.710 (2.54%)

Time: 00:58.737, Memory: 16.00 MB

OK (96 tests, 265 assertions)

Generating code coverage report in Clover XML format ... done [00:00.391]

Generating code coverage report in HTML format ... done [00:01.930]

Installation

Tachycardia should only be installed as a development-time dependency to aid in running your project's test suite. You can install using Composer:

composer require --dev nexusphp/tachycardia

Configuration

Tachycardia supports these parameters:

  • time-limit - Time limit in seconds to be enforced for all tests. All tests exceeding this amount will be considered as slow. Default: 1.00
  • report-count - Number of slow tests to be displayed in the console report. This is ignored on Github Actions report. Default: 10
  • precision - Degree of precision of the decimals of the test's consumed time and allotted time limit. Default: 4
  • format - The format of the renderer for the console.
  • ci-format - The format of the renderer for the CI.

Renderer formats for both the console and CI could be any of:

Format For Console? For CI? Remarks
list ✅︎ Default for console
table ✅︎
github ✅︎ ✅︎ Default for CI
gitlab ✅︎ ✅︎
teamcity ✅︎ ✅︎

To use the extension with its default configuration options, you can simply add the following into your phpunit.xml.dist or phpunit.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         cacheResultFile="build/.phpunit.cache/test-results"
         colors="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         failOnRisky="true"
         failOnWarning="true">

    <!-- Your other phpunit configurations here -->

    <extensions>
        <bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension" />
    </extensions>
</phpunit>

Now, run vendor/bin/phpunit. If there are test cases where the time consumed exceeds the configured time limits, these will be displayed in the console after all tests have completed.

If you wish to customize one or more of the available options, you can just change the entry in your phpunit.xml.dist or phpunit.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         cacheResultFile="build/.phpunit.cache/test-results"
         colors="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         failOnRisky="true"
         failOnWarning="true">

    <!-- Your other phpunit configurations here -->

    <extensions>
        <bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension">
            <parameter name="time-limit" value="2.00" />
            <parameter name="report-count" value="30" />
            <parameter name="precision" value="2" />
            <parameter name="format" value="table" />
            <parameter name="ci-format" value="github" />
        </bootstrap>
    </extensions>
</phpunit>

Documentation

Upgrading

Upgrading from v1.x to v2.x? See the UPGRADING Guide.

Contributing

Contributions are very much welcome. If you see an improvement or bug fix, open a PR now!

Read more on the Contributing to Nexus Tachycardia.

Inspiration

Tachycardia was inspired from johnkary/phpunit-speedtrap, but injected with anabolic steroids.

Tachycardia is actually a medical term referring to a heart rate that exceeds the normal resting rate in general of over 100 beats per minute.

License

This library is licensed under the MIT License.

nexusphp/tachycardia 适用场景与选型建议

nexusphp/tachycardia 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.3M 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 03 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 nexusphp/tachycardia 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.3M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 13
  • 依赖项目数: 25
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-20