Skip to content

PostMessage Cleanup - TodoMVC example (experimental) #509

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

flashdesignory
Copy link
Contributor

@flashdesignory flashdesignory commented Apr 21, 2025

This pr uses the todomvc web components workload and enables it for the post message api.
This is similar to what we've done for the news site example.

Benchmark changes

  • translations.mjs moved to the shared folder
  • helper methods are also moved into the above file, to be able to share them

Workload changes

  • installed the shared files (speedometer-utils)
  • updated / cleaned up the build script
  • created a workload-test.mjs file (with the identical test that's in the main test.mjs file)
  • injected an index.js file to enable the postmessage api

chrome:
Screenshot 2025-04-21 at 2 41 54 PM

safari:
Screenshot 2025-04-21 at 2 42 01 PM

todo: cb scores

Copy link

netlify bot commented Apr 21, 2025

Deploy Preview for webkit-speedometer-preview ready!

Name Link
🔨 Latest commit be6fa5f
🔍 Latest deploy log https://app.netlify.com/sites/webkit-speedometer-preview/deploys/681918e4fb6ab500084b77d4
😎 Deploy Preview https://deploy-preview-509--webkit-speedometer-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@flashdesignory flashdesignory marked this pull request as ready for review April 22, 2025 14:41
@flashdesignory flashdesignory changed the title PostMessage Cleanup - TodoMVC example PostMessage Cleanup - TodoMVC example (experimental) Apr 22, 2025
*************************************************************************/
export class BenchmarkConnector {
constructor(suites, name, version) {
this.suites = suites;
Copy link
Member

Choose a reason for hiding this comment

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

Why not use private variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a benefit in refactoring? Maybe that's a larger conversation if we want to prefer private variables in our code and might be better to tackle in a separate discussion. This is consistent with the previous example that uses the postMessage api and I rather want to avoid larger changes in a single pr.

*
* A single test step, with a common interface to interact with.
*/
export class BenchmarkStep {
Copy link
Member

Choose a reason for hiding this comment

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

It's not great that we're duplicating all this code.
We should figure out a way to share code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these files come from the ./resources/shared and are used in the workload by installing the local 'speedometer-utils' package. This links the files and keeps them in sync. This has been discussed and agreed on when I added the news site example that uses postMessage.

@@ -0,0 +1,195 @@
export class Params {
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't duplicate all this code. It would be a maintenance nightmare.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above comment :-)

@@ -0,0 +1,86 @@
class TestInvoker {
Copy link
Member

Choose a reason for hiding this comment

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

We should figure out a way to share code here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above comment :-)

@rniwa rniwa self-requested a review April 23, 2025 06:12
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

It looks good to me, but I think this can be somewhat improved.
Tell me what you think!

* @param {string} dest Destination directory.
*/
async function copyDirectory(src, dest) {
await fs.cp(src, dest, { recursive: true }, (err) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

note that cp was experimental until node v22.
I don't mind but it would be good to make sure everybody is OK with that and be explicit about us supporting node v22+.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah... that should be done in a follow up, since a few workloads use a similar script.
The workloads themselves typically pin a node version, so it's not super critical to fix right away.

if (err)
console.error(err);
});
await copyDirectory("./src", "./dist/src");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why you're not copying to /dist/ simply?
It looks like this would give less changes overall...

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 wanted to avoid to dump everything in the root of the dist folder.

@flashdesignory flashdesignory requested a review from julienw May 5, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants