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

plots: better support power use cases #2464

Merged
merged 17 commits into from
Jun 14, 2017

Conversation

wwwillchen
Copy link
Contributor

@wwwillchen wwwillchen commented Jun 7, 2017

This closes #2412

I'm copying the charts folder into each out directory because:

  • Needed a dynamic way to load generatedResults.js since the out folder can be an arbitrary name and I wanted to reduce the boilerplate of maintaining multiple charts page
  • I can't open a web page with query params using opn, so the initial load of charts/index.html has to bootstrap properly without any query params [0]
  • This makes it simpler to view older generated results, since each out directory has its own version of charts. This is helpful if you have old out dirs and the charts API has changed.

[0] Filed an issue here: sindresorhus/open#55

@@ -10,7 +10,6 @@
"first-meaningful-paint",
"speed-index-metric",
"estimated-input-latency",
"time-to-interactive",
Copy link
Collaborator

Choose a reason for hiding this comment

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

oops sorry :) **/*.js strikes again

Copy link
Member

Choose a reason for hiding this comment

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

true. @wwwillchen since you'll have to sort out this conflict anyhow...

can you change the plots.json to plots-config.js?

nice to have comments. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

are there back compat considerations? I'm guessing our existing plots data will need to be regenerated


/* eslint-env browser */

function parseQueryParameters(queryParams) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use URLSearchParams instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@wwwillchen
Copy link
Contributor Author

@patrickhulce for backwards compatibility:

  • yeah, existing out directories will need to be re-generated. It's a little dicey if it will work since, new metrics such as first-interactive cause analyze script to run into errors.
  • gh-pages plots source specific commits for charts so they should be OK

I think we can focus on backwards compat once plots over time (#2413) is implemented since it'll be vital then. For now, there's workarounds (e.g. checkout older lighthouse commit) to view old plots. Does that work for the team?

@patrickhulce
Copy link
Collaborator

I think we can focus on backwards compat once plots over time (#2413) is implemented since it'll be vital then. For now, there's workarounds (e.g. checkout older lighthouse commit) to view old plots. Does that work for the team?

Yeah sgtm, not a big deal until we have the historical view we'll want to preserve.

@@ -10,7 +10,6 @@
"first-meaningful-paint",
"speed-index-metric",
"estimated-input-latency",
"time-to-interactive",
Copy link
Member

Choose a reason for hiding this comment

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

true. @wwwillchen since you'll have to sort out this conflict anyhow...

can you change the plots.json to plots-config.js?

nice to have comments. ;)

@@ -16,14 +16,10 @@
</head>

<body>
<nav>
<nav id="nav">
Copy link
Member

Choose a reason for hiding this comment

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

u got some .html files in /plots to delete still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my b

* @return {string}
*/
function generateOutPath() {
if (args.out) {
Copy link
Member

Choose a reason for hiding this comment

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

missing readme docs on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

plots/utils.js Outdated
* @param {string} src
* @param {string} dest
*/
function copyRecursive(src, dest) {
Copy link
Member

Choose a reason for hiding this comment

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

lets use a module for this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

const queryParams = new URLSearchParams(window.location.search);
const chartParam = queryParams.get('chart') || './grouped-by-metric.js';

const chartScript = document.createElement('script');
Copy link
Member

Choose a reason for hiding this comment

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

this is a bit clunky, plus the three metrics files are already overlapping pretty hard.

let's merge all of charts/*.js into one file.

you can hook up generateBloxPlotPerSite(), or generateBoxPlotChartPerMetric(); generateLinePlotChartPerMetric(); or generateGroupedBarChart(); depending on which view we're in.

would rather have a simple slug (e.g. 'by-metric') in the query param or hash instead of a file or function name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

plots/utils.js Outdated
* @param {string} filePath
*/
function removeRecursive(filePath) {
try {
Copy link
Member

Choose a reason for hiding this comment

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

u can use rimraf

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've removed this (I think I can do away with it since I'm just copying the files individually into the correct out folder).

</nav>
<script src="./out/generatedResults.js"></script>
<script src="./bars-per-site.js"></script>
<script src="../generated-results.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

IMO if you're going to leave gen-results in the root of out then you should put index.html there 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.

OK.

plots/analyze.js Outdated
@@ -48,17 +57,17 @@ main();
function analyzeSite(sitePath) {
console.log('Analyzing', sitePath); // eslint-disable-line no-console
const runResults = [];
fs.readdirSync(sitePath).forEach(runDir => {
fs.readdirSync(sitePath).sort().forEach(runDir => {
Copy link
Member

Choose a reason for hiding this comment

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

dunno if it's useful but you might want to use localeCompare instead..

.sort((a, b) => a.localeCompare(b))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

@wwwillchen wwwillchen left a comment

Choose a reason for hiding this comment

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

@paulirish - please take another look.

@@ -10,7 +10,6 @@
"first-meaningful-paint",
"speed-index-metric",
"estimated-input-latency",
"time-to-interactive",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

plots/analyze.js Outdated
@@ -48,17 +57,17 @@ main();
function analyzeSite(sitePath) {
console.log('Analyzing', sitePath); // eslint-disable-line no-console
const runResults = [];
fs.readdirSync(sitePath).forEach(runDir => {
fs.readdirSync(sitePath).sort().forEach(runDir => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const queryParams = new URLSearchParams(window.location.search);
const chartParam = queryParams.get('chart') || './grouped-by-metric.js';

const chartScript = document.createElement('script');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -16,14 +16,10 @@
</head>

<body>
<nav>
<nav id="nav">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

my b

plots/utils.js Outdated
* @param {string} filePath
*/
function removeRecursive(filePath) {
try {
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've removed this (I think I can do away with it since I'm just copying the files individually into the correct out folder).

plots/utils.js Outdated
* @param {string} src
* @param {string} dest
*/
function copyRecursive(src, dest) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

* @return {string}
*/
function generateOutPath() {
if (args.out) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

</nav>
<script src="./out/generatedResults.js"></script>
<script src="./bars-per-site.js"></script>
<script src="../generated-results.js"></script>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

if (args.out) {
return path.resolve(__dirname, args.out);
}
const date = new Date().toISOString();
Copy link
Member

Choose a reason for hiding this comment

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

you'll need to replace colons in the ISOString

image

Copy link
Member

Choose a reason for hiding this comment

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

fixed.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@paulirish
Copy link
Member

added 3 commits that fix my remaining concerns. :)

@wwwillchen
Copy link
Contributor Author

@paulirish - thanks for the changes! let's merge?

@paulirish paulirish merged commit 3ccd170 into GoogleChrome:master Jun 14, 2017
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.

plots: better support power use cases
4 participants