Loading core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +23 −4 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\Core\Cache\Cache; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** Loading @@ -20,10 +21,19 @@ class OpenTelemetryFrontPagePerformanceTest extends PerformanceTestBase { */ protected $profile = 'demo_umami'; /** * Tests performance of the Umami demo front page. */ public function testFrontPagePerformance(): void { $this->testFrontPageColdCache(); $this->testFrontPageCoolCache(); $this->testFrontPageHotCache(); } /** * Logs front page tracing data with a cold cache. */ public function testFrontPageColdCache(): void { protected function testFrontPageColdCache(): void { // @todo Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // https://www.drupal.org/project/drupal/issues/3379750 Loading @@ -40,7 +50,7 @@ public function testFrontPageColdCache(): void { * * Hot here means that all possible caches are warmed. */ public function testFrontPageHotCache(): void { protected function testFrontPageHotCache(): void { // Request the page twice so that asset aggregates and image derivatives are // definitely cached in the browser cache. The first response builds the // file and serves from PHP with private, no-store headers. The second Loading Loading @@ -76,10 +86,10 @@ public function testFrontPageHotCache(): void { * Cool here means that 'global' site caches are warm but anything * specific to the front page is cold. */ public function testFrontPageCoolCache(): void { protected function testFrontPageCoolCache(): void { // First of all visit the front page to ensure the image style exists. $this->drupalGet('<front>'); $this->rebuildAll(); $this->clearCaches(); // Now visit a different page to warm non-route-specific caches. $this->drupalGet('user/login'); $this->collectPerformanceData(function () { Loading @@ -87,4 +97,13 @@ public function testFrontPageCoolCache(): void { }, 'umamiFrontPageCoolCache'); } /** * Clear caches. */ protected function clearCaches(): void { foreach (Cache::getBins() as $bin) { $bin->deleteAll(); } } } core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +26 −6 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\Core\Cache\Cache; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** Loading @@ -20,10 +21,20 @@ class OpenTelemetryNodePagePerformanceTest extends PerformanceTestBase { */ protected $profile = 'demo_umami'; /** * Test canonical node page performance with various cache permutations. */ public function testNodePage(): void { $this->testNodePageColdCache(); $this->testNodePageCoolCache(); $this->testNodePageWarmCache(); $this->testNodePageHotCache(); } /** * Logs node page tracing data with a cold cache. */ public function testNodePageColdCache(): void { protected function testNodePageColdCache(): void { // @todo Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // https://www.drupal.org/project/drupal/issues/3379750 Loading @@ -40,7 +51,7 @@ public function testNodePageColdCache(): void { * * Hot here means that all possible caches are warmed. */ public function testNodePageHotCache(): void { protected function testNodePageHotCache(): void { // Request the page twice so that asset aggregates are definitely cached in // the browser cache. $this->drupalGet('node/1'); Loading @@ -64,10 +75,10 @@ public function testNodePageHotCache(): void { * Cool here means that 'global' site caches are warm but anything * specific to the route or path is cold. */ public function testNodePageCoolCache(): void { protected function testNodePageCoolCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); $this->clearCaches(); // Now visit a non-node page to warm non-route-specific caches. $this->drupalGet('user/login'); $this->collectPerformanceData(function () { Loading @@ -82,10 +93,10 @@ public function testNodePageCoolCache(): void { * Warm here means that 'global' site caches and route-specific caches are * warm but caches specific to this particular node/path are not. */ public function testNodePageWarmCache(): void { protected function testNodePageWarmCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); $this->clearCaches(); // Now visit a different node page to warm non-path-specific caches. $this->drupalGet('node/2'); $this->collectPerformanceData(function () { Loading @@ -94,4 +105,13 @@ public function testNodePageWarmCache(): void { $this->assertSession()->pageTextContains('quiche'); } /** * Clear caches. */ protected function clearCaches(): void { foreach (Cache::getBins() as $bin) { $bin->deleteAll(); } } } core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.phpdeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group Performance */ class PerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Just load the front page. */ public function testPagesAnonymous(): void { $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); }); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); } /** * Load the front page as a user with access to Toolbar. */ public function testFrontPagePerformance(): void { $admin_user = $this->drupalCreateUser(['access toolbar']); $this->drupalLogin($admin_user); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(2, $performance_data->getScriptCount()); } } core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ * Stark is used as the default theme so that this test is not Olivero specific. * * @group Common * @group #slow * @requires extension apcu */ class StandardPerformanceTest extends PerformanceTestBase { Loading core/tests/Drupal/Tests/PerformanceTestTrait.php +0 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,6 @@ public function collectPerformanceData(callable $callable, ?string $service_name $session = $this->getSession(); $session->getDriver()->getWebDriverSession()->log('performance'); $collection = \Drupal::keyValue('performance_test'); $collection->deleteAll(); $return = $callable(); $performance_data = $this->processChromeDriverPerformanceLogs($service_name); Loading Loading
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +23 −4 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\Core\Cache\Cache; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** Loading @@ -20,10 +21,19 @@ class OpenTelemetryFrontPagePerformanceTest extends PerformanceTestBase { */ protected $profile = 'demo_umami'; /** * Tests performance of the Umami demo front page. */ public function testFrontPagePerformance(): void { $this->testFrontPageColdCache(); $this->testFrontPageCoolCache(); $this->testFrontPageHotCache(); } /** * Logs front page tracing data with a cold cache. */ public function testFrontPageColdCache(): void { protected function testFrontPageColdCache(): void { // @todo Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // https://www.drupal.org/project/drupal/issues/3379750 Loading @@ -40,7 +50,7 @@ public function testFrontPageColdCache(): void { * * Hot here means that all possible caches are warmed. */ public function testFrontPageHotCache(): void { protected function testFrontPageHotCache(): void { // Request the page twice so that asset aggregates and image derivatives are // definitely cached in the browser cache. The first response builds the // file and serves from PHP with private, no-store headers. The second Loading Loading @@ -76,10 +86,10 @@ public function testFrontPageHotCache(): void { * Cool here means that 'global' site caches are warm but anything * specific to the front page is cold. */ public function testFrontPageCoolCache(): void { protected function testFrontPageCoolCache(): void { // First of all visit the front page to ensure the image style exists. $this->drupalGet('<front>'); $this->rebuildAll(); $this->clearCaches(); // Now visit a different page to warm non-route-specific caches. $this->drupalGet('user/login'); $this->collectPerformanceData(function () { Loading @@ -87,4 +97,13 @@ public function testFrontPageCoolCache(): void { }, 'umamiFrontPageCoolCache'); } /** * Clear caches. */ protected function clearCaches(): void { foreach (Cache::getBins() as $bin) { $bin->deleteAll(); } } }
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +26 −6 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\Core\Cache\Cache; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** Loading @@ -20,10 +21,20 @@ class OpenTelemetryNodePagePerformanceTest extends PerformanceTestBase { */ protected $profile = 'demo_umami'; /** * Test canonical node page performance with various cache permutations. */ public function testNodePage(): void { $this->testNodePageColdCache(); $this->testNodePageCoolCache(); $this->testNodePageWarmCache(); $this->testNodePageHotCache(); } /** * Logs node page tracing data with a cold cache. */ public function testNodePageColdCache(): void { protected function testNodePageColdCache(): void { // @todo Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // https://www.drupal.org/project/drupal/issues/3379750 Loading @@ -40,7 +51,7 @@ public function testNodePageColdCache(): void { * * Hot here means that all possible caches are warmed. */ public function testNodePageHotCache(): void { protected function testNodePageHotCache(): void { // Request the page twice so that asset aggregates are definitely cached in // the browser cache. $this->drupalGet('node/1'); Loading @@ -64,10 +75,10 @@ public function testNodePageHotCache(): void { * Cool here means that 'global' site caches are warm but anything * specific to the route or path is cold. */ public function testNodePageCoolCache(): void { protected function testNodePageCoolCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); $this->clearCaches(); // Now visit a non-node page to warm non-route-specific caches. $this->drupalGet('user/login'); $this->collectPerformanceData(function () { Loading @@ -82,10 +93,10 @@ public function testNodePageCoolCache(): void { * Warm here means that 'global' site caches and route-specific caches are * warm but caches specific to this particular node/path are not. */ public function testNodePageWarmCache(): void { protected function testNodePageWarmCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); $this->clearCaches(); // Now visit a different node page to warm non-path-specific caches. $this->drupalGet('node/2'); $this->collectPerformanceData(function () { Loading @@ -94,4 +105,13 @@ public function testNodePageWarmCache(): void { $this->assertSession()->pageTextContains('quiche'); } /** * Clear caches. */ protected function clearCaches(): void { foreach (Cache::getBins() as $bin) { $bin->deleteAll(); } } }
core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.phpdeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group Performance */ class PerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Just load the front page. */ public function testPagesAnonymous(): void { $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); }); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); } /** * Load the front page as a user with access to Toolbar. */ public function testFrontPagePerformance(): void { $admin_user = $this->drupalCreateUser(['access toolbar']); $this->drupalLogin($admin_user); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(2, $performance_data->getScriptCount()); } }
core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ * Stark is used as the default theme so that this test is not Olivero specific. * * @group Common * @group #slow * @requires extension apcu */ class StandardPerformanceTest extends PerformanceTestBase { Loading
core/tests/Drupal/Tests/PerformanceTestTrait.php +0 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,6 @@ public function collectPerformanceData(callable $callable, ?string $service_name $session = $this->getSession(); $session->getDriver()->getWebDriverSession()->log('performance'); $collection = \Drupal::keyValue('performance_test'); $collection->deleteAll(); $return = $callable(); $performance_data = $this->processChromeDriverPerformanceLogs($service_name); Loading