Skip to content

Commit

Permalink
Add some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Nov 6, 2023
1 parent cca5dd3 commit 88aecd6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ jobs:
run: |
npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language plugin update de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language theme update de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
- name: Install MU plugin
run: |
Expand Down
7 changes: 5 additions & 2 deletions tests/performance/compare-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ console.log( 'Note: Due to the nature of how GitHub Actions work, some variance
* @param {number} value
*/
function formatValue( metric, value) {
if ( null === value ) {
return 'N/A';
}
if ( 'wpMemoryUsage' === metric ) {
return `${ ( value / Math.pow( 10, 6 ) ).toFixed( 2 ) } MB`;
}
Expand All @@ -161,9 +164,9 @@ for ( const key of testSuites ) {

for ( const [ metric, values ] of Object.entries( current ) ) {
const value = median( values );
const prevValue = median( prev[ metric ] );
const prevValue = prev[ metric ] ? median( prev[ metric ] ) : null;

const delta = value - prevValue;
const delta = null !== prevValue ? value - prevValue : 0
const percentage = ( delta / value ) * 100;
rows.push( {
Metric: metric,
Expand Down
2 changes: 2 additions & 0 deletions tests/performance/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { join } = require( 'node:path' );
const { median, getResultsFilename } = require( './utils' );

const testSuites = [
'admin',
'admin-l10n',
'home-classic-theme',
'home-classic-theme-l10n',
'home-block-theme',
Expand Down
6 changes: 2 additions & 4 deletions tests/performance/specs/admin-l10n.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { camelCaseDashes } from '../utils';

const results = {
timeToFirstByte: [],
largestContentfulPaint: [],
lcpMinusTtfb: [],
};

test.describe( 'Admin (L10N)', () => {
Expand Down Expand Up @@ -39,10 +37,10 @@ test.describe( 'Admin (L10N)', () => {
const iterations = Number( process.env.TEST_RUNS );
for ( let i = 1; i <= iterations; i++ ) {
test( `Measure load time metrics (${ i } of ${ iterations })`, async ( {
page,
admin,
metrics,
} ) => {
await page.goto( '/' );
await admin.visitAdminPage( '/' );

const serverTiming = await metrics.getServerTiming();

Expand Down
6 changes: 2 additions & 4 deletions tests/performance/specs/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { camelCaseDashes } from '../utils';

const results = {
timeToFirstByte: [],
largestContentfulPaint: [],
lcpMinusTtfb: [],
};

test.describe( 'Admin', () => {
Expand All @@ -33,10 +31,10 @@ test.describe( 'Admin', () => {
const iterations = Number( process.env.TEST_RUNS );
for ( let i = 1; i <= iterations; i++ ) {
test( `Measure load time metrics (${ i } of ${ iterations })`, async ( {
page,
admin,
metrics,
} ) => {
await page.goto( '/' );
await admin.visitAdminPage( '/' );

const serverTiming = await metrics.getServerTiming();

Expand Down
3 changes: 3 additions & 0 deletions tests/performance/wp-content/mu-plugins/server-timing.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ static function () use ( $server_timing_values, $template_start ) {

$server_timing_values['total'] = $server_timing_values['before-template'] + $server_timing_values['template'];

// While values passed via Server-Timing are intended to be durations,
// any numeric value can actually be passed.
// This is a nice little trick as it allows to easily get this information in JS.
$server_timing_values['memory-usage'] = memory_get_usage();

$header_values = array();
Expand Down

0 comments on commit 88aecd6

Please sign in to comment.