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

core: export any page-functions as string #5902

Merged
merged 4 commits into from
Sep 5, 2018
Merged

core: export any page-functions as string #5902

merged 4 commits into from
Sep 5, 2018

Conversation

midzer
Copy link
Contributor

@midzer midzer commented Aug 24, 2018

Summary

Export all functions in lib page-functions directly as string

Minor coding style i would say

Prettier code due not cluttering implementation files with multiple toString() calls

Related Issues/PRs
#5870

@patrickhulce
Copy link
Collaborator

thanks @midzer! @paulirish was specifically requesting this too :)

what do we think about adding a suffix to make it clear they are strings? I suppose the danger is less since toString'ing the string won't do much harm 🤷‍♀️

  • ultradumbBenchmarkFnString
  • ultradumbBenchmarkAsString
  • ultradumbBenchmarkStringified

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

..

@midzer
Copy link
Contributor Author

midzer commented Aug 24, 2018

@patrickhulce thanks for your suggestions. I'm totally up for this change. While looking a bit through LH code base, I've realized there are a couple of situations where variable type is put into it's name like

const errorString = 'Unable to locate '

for example. For me this resembles to https://en.wikipedia.org/wiki/Hungarian_notation with just a bit different flavour. Dunno whether there exists an exact term for this notation.

In rare cases something like ultradumbBenchmarkAsString is used already.

So I'm unsure which way to go to keep code base consistent for this kind of topic.

checkTimeSinceLastLongTask: checkTimeSinceLastLongTask.toString(),
getElementsInDocument: getElementsInDocument.toString(),
getOuterHTMLSnippet: getOuterHTMLSnippet.toString(),
ultradumbBenchmark: ultradumbBenchmark.toString(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

one wrinkle here we actually use this function as a function in scripts/benchmark.js

@patrickhulce
Copy link
Collaborator

So I'm unsure which way to go to keep code base consistent for this kind of topic.

It's not super consistent throughout the codebase, so I wouldn't put it on yourself to make it so ;)

In the file that a few of these functions were just moved from they were labeled FnString, so we can go with that for now?

@paulirish paulirish changed the title export any page-functions as string core: export any page-functions as string Aug 30, 2018
checkTimeSinceLastLongTaskString: checkTimeSinceLastLongTask.toString(),
getElementsInDocumentString: getElementsInDocument.toString(),
getOuterHTMLSnippetString: getOuterHTMLSnippet.toString(),
ultradumbBenchmark: ultradumbBenchmark,
Copy link
Member

Choose a reason for hiding this comment

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

this one is still toString()d within driver. can we update this one as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I had him change it back because we use the raw function in the scripts

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 both?

Copy link
Member

Choose a reason for hiding this comment

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

.gif

Copy link
Collaborator

Choose a reason for hiding this comment

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

both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't this break

const result = ultradumbBenchmark();
?

Copy link
Member

Choose a reason for hiding this comment

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

Nah. It's still exposed the same way. It's just ALSO being exposed as a string.

patrick didnt like my idea of only exposing as string and evaling in the script/benchmark.js. :) haha

@paulirish paulirish merged commit 552eaac into GoogleChrome:master Sep 5, 2018
@midzer midzer deleted the exportAsString branch September 5, 2018 02:58
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.

4 participants