function OpenTelemetryFrontPagePerformanceTest::testFrontPageColdCache

Logs front page tracing data with a cold cache.

1 call to OpenTelemetryFrontPagePerformanceTest::testFrontPageColdCache()
OpenTelemetryFrontPagePerformanceTest::testFrontPagePerformance in core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php
Tests performance of the Umami demo front page.

File

core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php, line 39

Class

OpenTelemetryFrontPagePerformanceTest
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' => 336,
    'CacheGetCount' => 388,
    'CacheSetCount' => 386,
    'CacheDeleteCount' => 0,
    'CacheTagLookupQueryCount' => 30,
    'CacheTagInvalidationCount' => 0,
    'ScriptCount' => 1,
    'ScriptBytes' => 12000,
    'StylesheetCount' => 2,
    '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.