Skip to content

Issue #3477191: Add PerformanceTestTrait::assertMetrics() so it is easier to...

Issue #3477191: Add PerformanceTestTrait::assertMetrics() so it is easier to write performance tests

Closes #3477191

For example :

// Previous way to assert metrics.
    $this->assertSame($expected_queries, $recorded_queries);
    $this->assertSame(124, $performance_data->getQueryCount());
    $this->assertSame(227, $performance_data->getCacheGetCount());
    $this->assertSame(190, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
    $this->assertCountBetween(30, 127, $performance_data->getCacheTagChecksumCount());
    $this->assertCountBetween(30, 39, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    $this->assertSame(1, $performance_data->getScriptCount());
    $this->assertCountBetween(212000, 213000, $performance_data->getScriptBytes());
    $this->assertSame(1, $performance_data->getStylesheetCount());
    $this->assertCountBetween(29500, 30500, $performance_data->getStylesheetBytes());

// New way to assert metrics.
    $expected_performance_data = new ExpectedPerformanceData();
    $expected_performance_data->setQueryCount(124);
    $expected_performance_data->setCacheGetCount(227);
    $expected_performance_data->setCacheSetCount(190);
    $expected_performance_data->setCacheDeleteCount(1);
    $expected_performance_data->setCacheTagChecksumCount(80, 50);
    $expected_performance_data->setCacheTagIsValidCount(35, 5);
    $expected_performance_data->setCacheTagInvalidationCount(0);
    $expected_performance_data->setScriptCount(1);
    $expected_performance_data->setScriptBytes(212500, 500);
    $expected_performance_data->setStylesheetCount(1);
    $expected_performance_data->setStylesheetBytes(30000, 500);
    $expected_performance_data->setQueries($expected_queries);
    $this->assertMetrics($performance_data, $expected_performance_data);

Merge request reports

Loading