Performance Symfony 2.8中的单元测试运行速度比实际速度慢数百倍
我将单元测试添加到以前从未有过的旧Symfony 2.8生产代码库中,以便将Symfony升级到维护版本。我们还将升级PHP,因为我们目前运行的是PHP5.5,它也不再维护,但如果在PHP7.3下运行,Symfony2.8会抛出太多错误 尽管我能够让单元测试在PHPUnit和Codeception(由PHPUnit提供支持)下运行,但它们运行得非常慢 例如: SimpleTest.php codeception.yml Codeception运行输出 此测试应始终在Performance Symfony 2.8中的单元测试运行速度比实际速度慢数百倍,performance,unit-testing,phpunit,symfony-2.8,php-5.5,Performance,Unit Testing,Phpunit,Symfony 2.8,Php 5.5,我将单元测试添加到以前从未有过的旧Symfony 2.8生产代码库中,以便将Symfony升级到维护版本。我们还将升级PHP,因为我们目前运行的是PHP5.5,它也不再维护,但如果在PHP7.3下运行,Symfony2.8会抛出太多错误 尽管我能够让单元测试在PHPUnit和Codeception(由PHPUnit提供支持)下运行,但它们运行得非常慢 例如: SimpleTest.php codeception.yml Codeception运行输出 此测试应始终在0.00s的时间内运行,总时间
0.00s
的时间内运行,总时间应小于5秒
,而不是20秒
或更长
如何在PHP5.5中的Symfony2.8下加速单元测试
我已经找到了运行PHP5.5的问题,这是目前的一个需求。我已经用PHP5.5创建了一个香草Symfony2.8安装,没有代码,测试速度仍然非常慢。当我切换到PHP7.3时,测试速度与我过去预期的一样快,但是,我们的项目还没有在PHP7.3下运行,因为它会导致致命错误
D:\server\Apache24\htdocs\symfony-2.8>php55 vendor\codeception\codeception\codecept run unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Unit Tests (1) --------------------------------------------------
+ SimpleTest: Should do nothing (0.20s)
-----------------------------------------------------------------
Time: 21.84 seconds, Memory: 14.50MB
OK (1 test, 1 assertion)
D:\server\Apache24\htdocs\symfony-2.8>php73 vendor\codeception\codeception\codecept run unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Unit Tests (1) --------------------------------------------------
+ SimpleTest: Should do nothing (0.00s)
-----------------------------------------------------------------
Time: 264 ms, Memory: 10.00MB
OK (1 test, 1 assertion)
您是否尝试禁用覆盖范围?每当我运行覆盖率测试时,总时间会增加20秒。这可能会使这个单一测试的速度减慢很多。@DirkScholten两者都是在没有覆盖的情况下运行的。覆盖率将6分钟的跑步变为1小时的跑步。您是否尝试禁用覆盖率?每当我运行覆盖率测试时,总时间会增加20秒。这可能会使这个单一测试的速度减慢很多。@DirkScholten两者都是在没有覆盖的情况下运行的。覆盖范围将6分钟的跑步变成了一小时的跑步。
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<php>
<server name="KERNEL_DIR" value="app/"/>
</php>
<testsuites>
<testsuite name="Application Test Suite">
<directory>tests/unit</directory>
</testsuite>
</testsuites>
</phpunit>
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Runtime: PHP 5.5.9 with Xdebug 2.5.5
.
Time: 19.52 seconds, Memory: 6.00MB
OK (1 test, 1 assertion)
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
include:
- src/*
low_limit: 50
high_limit: 100
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Unit Tests (1) --------------------------------------------------
Testing unit
+ SimpleTest: Should do nothing (0.29s)
-----------------------------------------------------------------
Time: 30.96 seconds, Memory: 23.25MB
OK (1 test, 1 assertion)
D:\server\Apache24\htdocs\symfony-2.8>php55 vendor\codeception\codeception\codecept run unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Unit Tests (1) --------------------------------------------------
+ SimpleTest: Should do nothing (0.20s)
-----------------------------------------------------------------
Time: 21.84 seconds, Memory: 14.50MB
OK (1 test, 1 assertion)
D:\server\Apache24\htdocs\symfony-2.8>php73 vendor\codeception\codeception\codecept run unit
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Unit Tests (1) --------------------------------------------------
+ SimpleTest: Should do nothing (0.00s)
-----------------------------------------------------------------
Time: 264 ms, Memory: 10.00MB
OK (1 test, 1 assertion)