function PerformanceTestTrait::calculateAllowedByteTolerance

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/PerformanceTestTrait.php \Drupal\Tests\PerformanceTestTrait::calculateAllowedByteTolerance()

Returns how much a bytes metric is allowed to vary without failing.

A range of bytes is allowed so that minor changes to CSS/JS files are possible without requiring performance test updates.

Parameters

int $bytes: The number of bytes.

Return value

int 2000 or 20% of the bytes, if that is lower.

2 calls to PerformanceTestTrait::calculateAllowedByteTolerance()
PerformanceTestTrait::assertMetrics in core/tests/Drupal/Tests/PerformanceTestTrait.php
Assert metrics from a performance data value object.
PerformanceTestTrait::assertMetricsByName in core/tests/Drupal/Tests/PerformanceTestTrait.php
Asserts metrics against the stored expectations.

File

core/tests/Drupal/Tests/PerformanceTestTrait.php, line 722

Class

PerformanceTestTrait
Provides various methods to aid in collecting performance data during tests.

Namespace

Drupal\Tests

Code

public function calculateAllowedByteTolerance(int $bytes) : int {
  return (int) min($bytes * 0.2, 2000);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.