function OpenTelemetryPerformanceTest::testFrontPageColdCache

Logs front page tracing data with a cold cache.

1 call to OpenTelemetryPerformanceTest::testFrontPageColdCache()
OpenTelemetryPerformanceTest::testUmamiPerformance in core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryPerformanceTest.php
Test performance of various with various cache permutations.

File

core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryPerformanceTest.php, line 334

Class

OpenTelemetryPerformanceTest
Tests demo_umami profile performance.

Namespace

Drupal\Tests\demo_umami\FunctionalJavascript

Code

protected function testFrontPageColdCache() : void {
  // Request the front page twice then clear caches, this allows asset
  // aggregate requests to complete so they are excluded from the performance
  // test itself. Including the asset aggregates would lead to
  // a non-deterministic test since they happen in parallel and therefore post
  // response tasks run in different orders each time.
  $this->drupalGet('<front>');
  $this->drupalGet('<front>');
  sleep(2);
  $this->clearCaches();
  $performance_data = $this->collectPerformanceData(function () {
    $this->drupalGet('<front>');
  }, 'umamiFrontPageColdCache');
  $this->assertSession()
    ->pageTextContains('Umami');
  $expected = [
    'QueryCount' => 178,
    'CacheGetCount' => 230,
    'CacheSetCount' => 241,
    'CacheDeleteCount' => 0,
    'CacheTagLookupQueryCount' => 24,
    'CacheTagInvalidationCount' => 0,
    'ScriptCount' => 3,
    'ScriptBytes' => 12000,
    'StylesheetCount' => 7,
    'StylesheetBytes' => 39150,
  ];
  $this->assertMetrics($expected, $performance_data);
}

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