Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log frontend perf results in codehealth #47442

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions bin/log-perormance-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
const fs = require( 'fs' );
const path = require( 'path' );
const https = require( 'https' );
const { mapKeys } = require( 'lodash' );
const [ token, branch, hash, baseHash, timestamp ] = process.argv.slice( 2 );

const performanceResults = JSON.parse(
fs.readFileSync(
path.join( __dirname, '../post-editor-performance-results.json' ),
'utf8'
const resultsFiles = [
{
file: 'post-editor-performance-results.json',
Copy link
Member

@oandregal oandregal Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to run this locally. I commented the parts that were about making the request to codehealth. Then, what I did was running the performance test and move the generated files to where this command expects them to be. For example, for post editor:

  • npm run test:performance -- --puppeteer-interactive packages/e2e-tests/specs/performance/post-editor.test.js
  • cp packages/e2e-tests/specs/performance/post-editor.test.results.json post-editor-performance-results.json

And similarly for the other two. Note that I had to rename the file, so I wonder if I missed another command? I guess my question is: are these paths expected?

Other than that, the command reported numbers, so it seems fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you need to run the comparison command ./bin/plugin/cli.js perf branch1 branch2 to get the right files.

metricsPrefix: '',
},
{
file: 'front-end-block-theme-performance-results.json',
metricsPrefix: 'block-theme-',
},
{
file: 'front-end-classic-theme-performance-results.json',
metricsPrefix: 'classic-theme-',
},
];

const performanceResults = resultsFiles.map( ( { file } ) =>
JSON.parse(
fs.readFileSync( path.join( __dirname, '../' + file ), 'utf8' )
)
);

Expand All @@ -21,8 +36,27 @@ const data = new TextEncoder().encode(
hash,
baseHash,
timestamp: parseInt( timestamp, 10 ),
metrics: performanceResults[ hash ],
baseMetrics: performanceResults[ baseHash ],
metrics: resultsFiles.reduce( ( result, { metricsPrefix }, index ) => {
return {
...result,
...mapKeys(
performanceResults[ index ][ hash ],
( _, key ) => metricsPrefix + key
),
};
}, {} ),
baseMetrics: resultsFiles.reduce(
( result, { metricsPrefix }, index ) => {
return {
...result,
...mapKeys(
performanceResults[ index ][ baseHash ],
( _, key ) => metricsPrefix + key
),
};
},
{}
),
} )
);

Expand Down