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

Perf testing: Cover Site Editor loading time #23842

Merged
merged 15 commits into from
Jul 16, 2020

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Jul 9, 2020

Description

Add some performance test coverage to the site editor (loading time), specifically to avoid perfomance regressions with regard to template resolution and wp_template auto-draft creation (see e.g. #23662).

Changes some of the underlying performance test framework to allow for multiple test files.

Fixes #23793.

How has this been tested?

npm run test-performance

In order to run the newly added tests interactively, use npm run test-performance -- site-editor.test.js --puppeteer-interactive.

Types of changes

Increase performance test coverage.

Question

Am I doing this right? Comparing the results file to the Post Editor's, the latter's loading time is 10x the Site Editor's. This seems almost too good to be true (altough it's true that the Site Editor probably loads fewer dependencies than the Post Editor). Is it possible to run perf/e2e tests and watch what they're doing?

Notes

Note that if you inspect this PR's 'Performance Tests' GH Action details, and expand the 'Run the performance tests' section there (and scroll to the bottom), you'll find that it actually fails upon trying to run npm run test-performance -- packages/e2e-tests/specs/performance/post-editor.performance.test.js. That is a file that was previously named performance.test.js, and is being renamed by this PR. It is being invoked by bin/plugin/commands/performance.js, which is also changed accordingly by this PR.

IIUC, the reason for the failure is that the GH Action is meant to compare performance for various branches, so it actually clones the master branch (which still has the old filenames) and runs the perf tests there (inside of a wp-env container that it spins up for that branch), but still uses the files from this branch to look for those test suite and results files. I don't see an easy fix, since we'd have to inject our updated files from this branch into that container. I think it should be fine to merge this branch, as the GH Action should start to work properly after that.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@ockham ockham added [Type] Performance Related to performance efforts [Feature] Full Site Editing [Package] E2E Tests /packages/e2e-tests labels Jul 9, 2020
@ockham ockham self-assigned this Jul 9, 2020
@github-actions
Copy link

github-actions bot commented Jul 9, 2020

Size Change: -1.02 MB (88%) 🏆

Total Size: 1.15 MB

Filename Size Change
build/a11y/index.js 0 B -1.14 kB (0%)
build/annotations/index.js 0 B -3.67 kB (0%)
build/api-fetch/index.js 0 B -3.39 kB (0%)
build/autop/index.js 0 B -2.82 kB (0%)
build/blob/index.js 0 B -620 B (0%)
build/block-directory/index.js 0 B -7.67 kB (0%)
build/block-editor/index.js 0 B -115 kB (0%)
build/block-editor/style-rtl.css 10.8 kB +29 B (0%)
build/block-editor/style.css 10.8 kB +28 B (0%)
build/block-library/index.js 0 B -132 kB (0%)
build/block-serialization-default-parser/index.js 0 B -1.88 kB (0%)
build/block-serialization-spec-parser/index.js 0 B -3.1 kB (0%)
build/blocks/index.js 0 B -48.2 kB (0%)
build/components/index.js 0 B -199 kB (0%)
build/components/style-rtl.css 15.6 kB -232 B (1%)
build/components/style.css 15.6 kB -227 B (1%)
build/compose/index.js 0 B -9.67 kB (0%)
build/core-data/index.js 0 B -11.4 kB (0%)
build/data-controls/index.js 0 B -1.29 kB (0%)
build/data/index.js 0 B -8.46 kB (0%)
build/date/index.js 0 B -5.38 kB (0%)
build/deprecated/index.js 0 B -772 B (0%)
build/dom-ready/index.js 0 B -569 B (0%)
build/dom/index.js 0 B -3.23 kB (0%)
build/edit-navigation/index.js 0 B -10.8 kB (0%)
build/edit-post/index.js 0 B -304 kB (0%)
build/edit-post/style-rtl.css 5.61 kB +20 B (0%)
build/edit-post/style.css 5.61 kB +20 B (0%)
build/edit-site/index.js 0 B -16.6 kB (0%)
build/edit-site/style-rtl.css 3.04 kB +11 B (0%)
build/edit-site/style.css 3.04 kB +12 B (0%)
build/edit-widgets/index.js 0 B -9.35 kB (0%)
build/editor/index.js 0 B -45.1 kB (0%)
build/element/index.js 0 B -4.65 kB (0%)
build/escape-html/index.js 0 B -733 B (0%)
build/format-library/index.js 0 B -7.72 kB (0%)
build/hooks/index.js 0 B -2.13 kB (0%)
build/html-entities/index.js 0 B -622 B (0%)
build/i18n/index.js 0 B -3.56 kB (0%)
build/is-shallow-equal/index.js 0 B -709 B (0%)
build/keyboard-shortcuts/index.js 0 B -2.51 kB (0%)
build/keycodes/index.js 0 B -1.94 kB (0%)
build/list-reusable-blocks/index.js 0 B -3.12 kB (0%)
build/media-utils/index.js 0 B -5.32 kB (0%)
build/notices/index.js 0 B -1.79 kB (0%)
build/nux/index.js 0 B -3.4 kB (0%)
build/plugins/index.js 0 B -2.56 kB (0%)
build/primitives/index.js 0 B -1.4 kB (0%)
build/priority-queue/index.js 0 B -789 B (0%)
build/redux-routine/index.js 0 B -2.85 kB (0%)
build/rich-text/index.js 0 B -13.9 kB (0%)
build/server-side-render/index.js 0 B -2.71 kB (0%)
build/shortcode/index.js 0 B -1.7 kB (0%)
build/token-list/index.js 0 B -1.27 kB (0%)
build/url/index.js 0 B -4.06 kB (0%)
build/viewport/index.js 0 B -1.85 kB (0%)
build/warning/index.js 0 B -1.13 kB (0%)
build/wordcount/index.js 0 B -1.17 kB (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.min.js 1.14 kB 0 B
build/annotations/index.min.js 3.67 kB 0 B
build/api-fetch/index.min.js 3.43 kB 0 B
build/autop/index.min.js 2.82 kB 0 B
build/blob/index.min.js 620 B 0 B
build/block-directory/index.min.js 7.63 kB 0 B
build/block-directory/style-rtl.css 944 B 0 B
build/block-directory/style.css 945 B 0 B
build/block-editor/index.min.js 124 kB 0 B
build/block-library/editor-rtl.css 7.6 kB 0 B
build/block-library/editor.css 7.59 kB 0 B
build/block-library/index.min.js 132 kB 0 B
build/block-library/style-rtl.css 7.77 kB 0 B
build/block-library/style.css 7.77 kB 0 B
build/block-library/theme-rtl.css 728 B 0 B
build/block-library/theme.css 729 B 0 B
build/block-serialization-default-parser/index.min.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.min.js 3.1 kB 0 B
build/blocks/index.min.js 48.3 kB 0 B
build/components/index.min.js 200 kB 0 B
build/compose/index.min.js 9.67 kB 0 B
build/core-data/index.min.js 11.5 kB 0 B
build/data-controls/index.min.js 1.29 kB 0 B
build/data/index.min.js 8.45 kB 0 B
build/date/index.min.js 5.38 kB 0 B
build/deprecated/index.min.js 772 B 0 B
build/dom-ready/index.min.js 568 B 0 B
build/dom/index.min.js 3.23 kB 0 B
build/edit-navigation/index.min.js 10.8 kB 0 B
build/edit-navigation/style-rtl.css 1.08 kB 0 B
build/edit-navigation/style.css 1.08 kB 0 B
build/edit-post/index.min.js 304 kB 0 B
build/edit-site/index.min.js 16.8 kB 0 B
build/edit-widgets/index.min.js 9.35 kB 0 B
build/edit-widgets/style-rtl.css 2.45 kB 0 B
build/edit-widgets/style.css 2.45 kB 0 B
build/editor/editor-styles-rtl.css 537 B 0 B
build/editor/editor-styles.css 539 B 0 B
build/editor/index.min.js 45.1 kB 0 B
build/editor/style-rtl.css 3.78 kB 0 B
build/editor/style.css 3.78 kB 0 B
build/element/index.min.js 4.65 kB 0 B
build/escape-html/index.min.js 733 B 0 B
build/format-library/index.min.js 7.72 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.min.js 2.13 kB 0 B
build/html-entities/index.min.js 621 B 0 B
build/i18n/index.min.js 3.56 kB 0 B
build/is-shallow-equal/index.min.js 711 B 0 B
build/keyboard-shortcuts/index.min.js 2.51 kB 0 B
build/keycodes/index.min.js 1.94 kB 0 B
build/list-reusable-blocks/index.min.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.min.js 5.32 kB 0 B
build/notices/index.min.js 1.79 kB 0 B
build/nux/index.min.js 3.4 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.min.js 2.56 kB 0 B
build/primitives/index.min.js 1.4 kB 0 B
build/priority-queue/index.min.js 789 B 0 B
build/redux-routine/index.min.js 2.85 kB 0 B
build/rich-text/index.min.js 13.9 kB 0 B
build/server-side-render/index.min.js 2.71 kB 0 B
build/shortcode/index.min.js 1.7 kB 0 B
build/token-list/index.min.js 1.27 kB 0 B
build/url/index.min.js 4.06 kB 0 B
build/viewport/index.min.js 1.85 kB 0 B
build/warning/index.min.js 1.14 kB 0 B
build/wordcount/index.min.js 1.17 kB 0 B

compressed-size-action

@ockham ockham marked this pull request as ready for review July 13, 2020 15:19
Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

Is it possible to run perf/e2e tests and watch what they're doing?

For e2e tests, yes, you just have to pass some flags. See here: https://github.com/WordPress/gutenberg/blob/master/docs/contributors/testing-overview.md#end-to-end-testing

e.g. npm run test-e2e:watch -- --puppeteer-interactive

I'm not sure if that also works with the perf test, but since it uses puppeteer, I imagine it would work if you passed that flag to the right script :)

the latter's loading time is 10x the Site Editor's

This does make sense to me since we have significantly fewer dependencies here. We also load less stuff synchronously on load with PHP. So templates are queried from WordPress after the initial dom loads. (I don't think that is the case with the post editor, which probably tests it loading with a lot of blocks initially.)

think it should be fine to merge this branch, as the GH Action should start to work properly after that.

I'm onboard with this so long as we verify that it starts working directly afterwards!

This PR looks pretty good to me 👍 I'll give a ✅ but would recommend waiting to merge for feedback from some other folks (maybe @youknowriad has some thoughts). since my knowledge of this code is limited


// Measuring loading time
while ( i-- ) {
await page.reload( { waitUntil: [ 'domcontentloaded', 'load' ] } );
Copy link
Member

Choose a reason for hiding this comment

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

Should we wait until the template has loaded on the page? I think this just measures document load, but there is another delay of a few seconds until the template is loaded from the API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. What would be the best way to implement this? Add a waitForSelector for a thing that's only in the template? 🤔

@noahtallen
Copy link
Member

That said, I wonder about the test failing:

  • why doesn't it cause CI to fail with a ❌
  • is it possible to throw a more helpful error message if a file does not exist?

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Seems like we should fix the CI before moving forward.

@@ -220,21 +222,32 @@ async function runPerformanceTests( branches, options ) {
log( '>> Starting the WordPress environment' );
await runShellScript( 'npm run wp-env start', environmentDirectory );

/** @type {Record<string, WPFormattedPerformanceResults>} */
const testSuites = [ 'post-editor', 'site-editor' ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an argument instead of running all tests with default to post-editor? or do you think we should be running all tests everytime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in the function body of runPerformanceTests, which is the top-level export of this file (invoked by bin/plugin/cli.js). If we want to make this an argument, we'd basically have to make it one that's passed by the CLI.

I'm leaning towards always running both perf suites. Their main use case is CI (the GH Action), as this is the most reliable guard against perf regressions, so it should IMO be easy to monitor that. Furthermore, the Site Editor test only covers loading time, which is currently pretty short. We can revisit if we add more coverage and testing times grow too much.

bin/plugin/commands/performance.js Outdated Show resolved Hide resolved
@ockham
Copy link
Contributor Author

ockham commented Jul 14, 2020

Seems like we should fix the CI before moving forward.

Can you elaborate? Do you mean that it should be failing, since the perf test is throwing an error (that's being silently ignored)? I overall agree, but then I'll also need to fix the underlying issue -- which I think is only present on this branch (but will go away once merged to master, see PR desc). Fixing it will probably involve injecting a branch's perf test files into the repo clone that ./bin/plugin/cli.js perf downloads (rather than using that clone's), and I'm having trouble getting that command to pass on my Linux system because of file permission issues (a known and recurring issue with wp-env). Long story short -- it'd be quite the blocker to sort all these things out.

As an alternative, maybe someone with macOS can run ./bin/plugin/cli.js perf locally and confirm that it works (and post results here)?

@youknowriad
Copy link
Contributor

Can you elaborate? Do you mean that it should be failing, since the perf test is throwing an error (that's being silently ignored)?

ideally yes, at least it shouldn't fail (silently or not). In other PRs, the test seem to be passing properly. (I do see the console.log in the output)

@youknowriad
Copy link
Contributor

Oh now, I understand. This is only failing because the file has been renamed in master. This makes me thing, the same will happen when we'll do ./bin/plugin/cli.js perf v8.5.0 v8.6.0 for the next release. Do you think there's a way to make it pass for old branches too somehow?

@youknowriad
Copy link
Contributor

ut still uses the files from this branch to look for those test suite and results files. I don't see an easy fix, since we'd have to inject our updated files from this branch into that container.

I think the perf command should be using master for the test and the results. At least that's how I wrote it/imagined it. That way it works regardless of the branch you're testing. The branches are only used to setup the WP+gutenberg environment.

@@ -147,13 +149,13 @@ async function getPerformanceResultsForBranch(
const results = [];
for ( let i = 0; i < 3; i++ ) {
await runShellScript(
'npm run test-performance',
`npm run test-performance -- packages/e2e-tests/specs/performance/${ testSuite }.test.js`,
Copy link
Contributor

Choose a reason for hiding this comment

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

So this seems to be the change that's causing issues in the Github action. We're changing the API of npm run test-performance. Can't we just leave it as is? basically run all performance tests when you do npm run test-performance? This is documented already in several places and I'm not sure we should be breaking this assumption?

Alternatively, we could have:

npm run test-performance // runs post editor tests
npm run test-performance --suite="posteditor" // runs post editor tests
npm run test-performance --suite="site-editor" // runs site editor tests

This will ensure we don't break the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's only one side of the medal though, since master only produces one results.json file for the post editor only, whereas this branch renames that file to post-editor.results.json, and writes the site editor results to site-editor.results.json.

In fact, an earlier version of this PR had npm run test-performance (with no added args), and that caused the GH action to fail when looking for post-editor.results.json, since master had only produced results.json.

I'm not sure we can retain API stability this way, and add test coverage for a different test suite. We'd be extremely limited in our options, and things might end up rather hacky (something like adding site-editor specific fields to results.json, while retaining the post-editor ones without even renaming them -- sounds like it could become quite messy and hard to understand/maintain/extend quickly).

Overall, I'm not convinced that that's the right approach; the requirement of this kind of API stability basically means we can never significantly change perf tests, and that's just a really tough constraint, since it's really hard to anticipate whatever needs might arise in the future.

Wouldn't it make sense that a branch that changes perf tests uses those tests to run on both that branch, and master?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm you're right, I can see that. I guess an alternative here could be to make ./bin/plugin/cli.js take an optional "branch" where if specified, we run the perf tests from that branch instead of "master" and we could use that argument in the github action? Any thoughts on that?

Regardless, though, if we change the signature of npm run test-performance we should make sure to update the docs, having a --suite option or something like that is a bit nicer than having to pass the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, still a few more questions 😅

Mmm you're right, I can see that. I guess an alternative here could be to make ./bin/plugin/cli.js take an optional "branch" where if specified, we run the perf tests from that branch instead of "master" and we could use that argument in the github action? Any thoughts on that?

This is actually an interface where I am wondering if we need to add more options: Do we need the extra argument? Doesn't it make sense to always use the branch's tests? For most branches, those will be identical to master's anyway, so it doesn't really make a difference there. But if a branch does modify them, we surely wanna use them, no?

Regardless, though, if we change the signature of npm run test-performance we should make sure to update the docs, having a --suite option or something like that is a bit nicer than having to pass the file.

I don't mind adding that. Personally, I actually like the 'pass-through' approach (i.e. the npm ... -- ... syntax), mostly for its discoverability -- I didn't really look at any code but just tried it, and it did the right thing. I find that quite intuitive (and it's always the first thing I try when needing to pass a filename to an npm script). I prefer this uniform syntax over the 'nice' one, but I'm happy to go along with the 'nice' one.


Finally: To make the actual change, we'll have to insert the branch's test files into the wp-env container. As I said, this might be kinda painful (or even near-impossible currently) to test on my Linux box, where there's always some permissions issue when attempting to add or change files in those Docker images (and I haven't been able to fully track down that issue for a while -- wp-env works for most purposes for me, just not for stuff that requires write access, e.g. uploading media files). My alternative suggestion would be to merge without those changes, verify that the new perf test behavior works fine (and revert if it doesn't), and tackle that perf test file injection in a separate PR. Would you be okay with that? 😬

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the extra argument?

We need to run the same tests across branches ./bin/plugin/cli.js branchA branchB runs the master tests in the environment built using branchA and branchB and compare both.

I was suggesting something like ./bin/plugin/cli.js branchA branchB --testsBranch branchC to run the branchC tests in the environment built using branchA and branchB and compare both.

In the Github action BranchC will be equal to branchA though but that's fine.

--suite config

I don't feel strongly here, the important thing is that the docs stay correct whichever choice you make.

Finally: To make the actual change, we'll have to insert the branch's test files into the wp-env container.

I think it's just a matter of calling git checkout branchC at the beginning of the perf command (when setting up the perf environment directory)

Copy link
Contributor

Choose a reason for hiding this comment

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

The rare situations where we had to make something work in different branches differently came down so far, to selector changes to open the inserter but that doesn't have an impact on any metric.

The metric is simple: - type a character, click on a block, load the page... These are the things that need to be computed similarly across branches and these things don't differ depending on the branch the test is used for. So for me personally, I think the testsBranch argument is doing its work properly so far.

Copy link
Member

Choose a reason for hiding this comment

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

I will take your word for it; I don't understand what that work properly is, other than there was a PR where filenames changed and something crashed because of the lack of a tests branch. Thanks for helping clarity this! It's not a big problem that I'm seeing; was mostly just trying to remove things I don't think we need.

Copy link
Member

Choose a reason for hiding this comment

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

For instance, if we change code that break performance tests, we need to update in the same PR the tests to run both with the new updated code but we also need to ensure the tests continue to run properly if applied to trunk (previous code).

@youknowriad I'm coming back to this and trying to better understand what you wrote here; I'm wondering if you are saying that you suspect that test changes will work in a PR but then fail when run on trunk.

One thing I discovered while working on our test suites is that we don't run tests against the PR's branch, but the "PR's merge branch." The merge branch is a branch which tracks the PR but every time we make a commit it creates a hypothetical merge of that branch tip into the target branch (usually trunk).

What this means is that if in a PR we make changes to a test suite, then when those changes run in CI and we're relying on $GITHUB_SHA (as we do), then the tests already incorporate the issues of merging back into trunk. If the new test files would break in trunk they would also break on the $GITHUB_SHA.

I know that at that point in that PR we're comparing two different test suites, but by providing --tests-branch we're changing the equation from "the results in the PR comparing trunk to the changes are invalid" into "the results in trunk comparing one commit to the previous commit are invalid."

Since we only report performance changes in mainline trunk I'm still struggling to see how --tests-branch helps us achieve the goal we say it does.

cc: @ockham

But also, say we change the way we compute some metric "typing" or something like that, if we decide to run different tests on different branches (say the branches tests), the results will be completely different between the branches so comparing them wouldn't make sense anymore.

This is another thing I think I've been uncovering as a hidden assumption, that our results are consistent within test runs. Even with running each branch 3x I'm seeing routine variation between the branches on the perf tests, frequently hitting more than 2x difference when no difference exists. I'm going to start trying to gather some statistics on the values from individual PR runs so we can discuss the facts of the measurements we're making, but I know already for a fact that the way we talk about these measurements in the PRs doesn't match the reality I've seen.

For example, I make a change to README.md and in the performance tests (after 3x runs and taking the median) it shows that my branch loads the editor in half the time as it does in trunk and yet trunk is 2x faster when typing. The test code is the same, the code under test is the same, but our test runtime variance is so much wider than the time it takes to run the code we're testing that our results are probably mostly random variation.

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, I make a change to README.md and in the performance tests (after 3x runs and taking the median) it shows that my branch loads the editor in half the time as it does in trunk and yet trunk is 2x faster when typing. $

If this is happening for any of the metrics we track in https://codehealth.vercel.app then it's a problem yes. But in my experience I only saw it in site editor metrics. These are more recent and we didn't work on their stability yet so I don't think we can trust them just yet. It's just a vague indication for now. But for the post editor metrics tracked on the site, I've not seen any major stability issues like that. I do see small variances (you can look at the graphs) but any important change has correlated well with an impactful commit.

Copy link
Member

@dmsnell dmsnell Nov 14, 2022

Choose a reason for hiding this comment

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

Just for some context, @youknowriad, I'm trying to start gathering data on this in #45747 and in at least the first batch of 30 test runs I found that 22 of them showed results at least as different on the type event (in the post editor) as the reported change from 14.4 to 14.5 was - 10 of which were more than that many ms faster, and 12 of which were more than that many ms slower.

How are you measuring variance and correlation? I have to be missing something because it looks like the data is explained primarily by random variation. That is, if there is an impact, I'd like to know how you were able to pull it out of the noise caused by random variation which seems to have a bigger impact than any reported change.

In the meantime I'll spin up a PR that specifically tests that release and see if I can reproduce the measurements you found.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I think there's a mention of npm run test-performance in the testing-overview.md that needs to be updated, otherwise, this is looking good.

@ockham
Copy link
Contributor Author

ockham commented Jul 15, 2020

Is it possible to run perf/e2e tests and watch what they're doing?

For e2e tests, yes, you just have to pass some flags. See here: https://github.com/WordPress/gutenberg/blob/master/docs/contributors/testing-overview.md#end-to-end-testing

e.g. npm run test-e2e:watch -- --puppeteer-interactive

I'm not sure if that also works with the perf test, but since it uses puppeteer, I imagine it would work if you passed that flag to the right script :)

Thanks! npm run test-performance -- --puppeteer-interactive works. I can even narrow it down to just the Site Editor tests via npm run test-performance -- site-editor.test.js --puppeteer-interactive.

the latter's loading time is 10x the Site Editor's

This does make sense to me since we have significantly fewer dependencies here. We also load less stuff synchronously on load with PHP. So templates are queried from WordPress after the initial dom loads. (I don't think that is the case with the post editor, which probably tests it loading with a lot of blocks initially.)

👍

@youknowriad
Copy link
Contributor

youknowriad commented Jul 15, 2020

Capture d’écran 2020-07-15 à 8 17 58 PM

Seems like the command is failing on the github action?

@ockham
Copy link
Contributor Author

ockham commented Jul 15, 2020

Capture d’écran 2020-07-15 à 8 17 58 PM

Seems like the command is failing on the github action?

Yeah, I was just looking into this 😕

I ran the tests locally in interactive mode and noticed that I need to add an await before visitAdminPage as pupeteer would otherwise simply not navigate there. I'll push the commit (but I'm not totally sure that's the reason for the error in th GH Action).

@ockham
Copy link
Contributor Author

ockham commented Jul 15, 2020

They're passing! 🎉

image

I'll try removing the nasty non-numeric columns 😬

@ockham
Copy link
Contributor Author

ockham commented Jul 15, 2020

I'll try removing the nasty non-numeric columns

This is better:

image

@ockham
Copy link
Contributor Author

ockham commented Jul 15, 2020

Should be ready for final approval 🎉

};

// Remove results for which we don't have data (and where the statistical functions thus returned NaN or Infinity etc).
const finiteMedians = pickBy( medians, isFinite );
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this has an impact on the WPFormattedPerformanceResults type? things should be made optional there right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

missed this somehow 😬 😄

@ockham ockham merged commit 04a7924 into master Jul 16, 2020
@ockham ockham deleted the add/site-editor-performance-test branch July 16, 2020 11:29
@github-actions github-actions bot added this to the Gutenberg 8.6 milestone Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Tests /packages/e2e-tests [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perf testing: Cover Site Editor loading time
4 participants