Make WordPress Core

Changeset 57083


Ignore:
Timestamp:
11/08/2023 10:30:21 AM (3 years ago)
Author:
swissspidy
Message:

Build/Test Tools: Expand performance test scenarios.

Adds new tests for localized sites as well as the dashboard.
Also amends Server-Timing output to measure memory usage in all scenarios.

Props swissspidy, joemcgill, flixos90, mukesh27, mamaduka.
See #59656.
Fixes #59815.

Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/performance.yml

    r56972 r57083  
    163163          npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}
    164164
     165      - name: Install additional languages
     166        run: |
     167          npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}
     168          npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
     169          npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
     170
    165171      - name: Install MU plugin
    166172        run: |
  • trunk/tests/performance/compare-results.js

    r56934 r57083  
    2424
    2525// The list of test suites to log.
    26 const testSuites = [ 'home-block-theme', 'home-classic-theme' ];
     26const testSuites = [
     27        'admin',
     28        'admin-l10n',
     29        'home-block-theme',
     30        'home-block-theme-l10n',
     31        'home-classic-theme',
     32        'home-classic-theme-l10n',
     33];
    2734
    2835// The current commit's results.
     
    129136console.log( 'Note: Due to the nature of how GitHub Actions work, some variance in the results is expected.\n' );
    130137
     138/**
     139 * Nicely formats a given value.
     140 *
     141 * @param {string} metric Metric.
     142 * @param {number} value
     143 */
     144function formatValue( metric, value) {
     145        if ( null === value ) {
     146                return 'N/A';
     147        }
     148        if ( 'wpMemoryUsage' === metric ) {
     149                return `${ ( value / Math.pow( 10, 6 ) ).toFixed( 2 ) } MB`;
     150        }
     151
     152        return `${ value.toFixed( 2 ) } ms`;
     153}
     154
    131155for ( const key of testSuites ) {
    132156        const current = testResults[ key ] || {};
     
    142166        for ( const [ metric, values ] of Object.entries( current ) ) {
    143167                const value = median( values );
    144                 const prevValue = median( prev[ metric ] );
     168                const prevValue = prev[ metric ] ? median( prev[ metric ] ) : null;
    145169
    146                 const delta = value - prevValue;
     170                const delta = null !== prevValue ? value - prevValue : 0
    147171                const percentage = ( delta / value ) * 100;
    148172                rows.push( {
    149173                        Metric: metric,
    150                         Before: `${ prevValue.toFixed( 2 ) } ms`,
    151                         After: `${ value.toFixed( 2 ) } ms`,
    152                         'Diff abs.': `${ delta.toFixed( 2 ) } ms`,
     174                        Before: formatValue( metric, prevValue ),
     175                        After: formatValue( metric, value ),
     176                        'Diff abs.': formatValue( metric, delta ),
    153177                        'Diff %': `${ percentage.toFixed( 2 ) } %`,
    154178                } );
  • trunk/tests/performance/log-results.js

    r55459 r57083  
    1212// The list of test suites to log.
    1313const testSuites = [
     14        'admin',
     15        'admin-l10n',
    1416        'home-block-theme',
     17        'home-block-theme-l10n',
    1518        'home-classic-theme',
     19        'home-classic-theme-l10n',
    1620];
    1721
  • trunk/tests/performance/playwright.config.js

    r56926 r57083  
    2020        ...baseConfig,
    2121        globalSetup: require.resolve( './config/global-setup.js' ),
    22         reporter: process.env.CI
    23                 ? './config/performance-reporter.js'
    24                 : [ [ 'list' ], [ './config/performance-reporter.js' ] ],
     22        reporter: [ [ 'list' ], [ './config/performance-reporter.js' ] ],
    2523        forbidOnly: !! process.env.CI,
    2624        workers: 1,
  • trunk/tests/performance/results.js

    r56926 r57083  
    99
    1010const testSuites = [
     11    'admin',
     12    'admin-l10n',
    1113    'home-classic-theme',
     14    'home-classic-theme-l10n',
    1215    'home-block-theme',
     16    'home-block-theme-l10n',
    1317];
    1418
  • trunk/tests/performance/specs/home-block-theme.test.js

    r56926 r57083  
    4242                        const serverTiming = await metrics.getServerTiming();
    4343
    44                         for ( const [key, value] of Object.entries( serverTiming ) ) {
     44                        for ( const [ key, value ] of Object.entries( serverTiming ) ) {
    4545                                results[ camelCaseDashes( key ) ] ??= [];
    4646                                results[ camelCaseDashes( key ) ].push( value );
  • trunk/tests/performance/specs/home-classic-theme.test.js

    r56926 r57083  
    4141                        const serverTiming = await metrics.getServerTiming();
    4242
    43                         for (const [key, value] of Object.entries( serverTiming ) ) {
     43                        for ( const [ key, value ] of Object.entries( serverTiming ) ) {
    4444                                results[ camelCaseDashes( key ) ] ??= [];
    4545                                results[ camelCaseDashes( key ) ].push( value );
  • trunk/tests/performance/wp-content/mu-plugins/server-timing.php

    r56559 r57083  
    2626                                $server_timing_values['total'] = $server_timing_values['before-template'] + $server_timing_values['template'];
    2727
     28                                /*
     29                                 * While values passed via Server-Timing are intended to be durations,
     30                                 * any numeric value can actually be passed.
     31                                 * This is a nice little trick as it allows to easily get this information in JS.
     32                                 */
     33                                $server_timing_values['memory-usage'] = memory_get_usage();
     34
    2835                                $header_values = array();
    2936                                foreach ( $server_timing_values as $slug => $value ) {
Note: See TracChangeset for help on using the changeset viewer.