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: A/B screenshot viewer #2026

Merged
merged 12 commits into from
Apr 25, 2017

Conversation

wwwillchen
Copy link
Contributor

Purpose

This enables the lighthouse team to better understand how changes to perf metrics (e.g. the algorithm for FMP) affect the perf results of real world sites.

Mode A: Aligned Screenshot Timeline

This enables easy head-to-head comparison between runs for the same site or even runs across different sites. To make the timeline less cluttered, I only show some of the screenshots.

Example:
screenshot-viewer-aligned-timeline

Mode B: Non-Aligned Screenshot Timeline

This shows more detail than the other mode and shows every screenshot collected.

Example:
screenshot-viewer-unaligned-timeline

If this tool proves to be useful - we can work on making it easy to use for external users. For example, I can imagine a product manager be very interested in the Aligned Screenshot Timeline View for their company and top 3 competitors.

Closes part of #1980

const ssJSONFilename = 'the_file-0.screenshots.json';
const ssFileContents = fs.readFileSync(ssJSONFilename, 'utf8');
const expectedScreenshotContent = '"timestamp": 674089419.919,';
assert.ok(ssFileContents.includes(expectedScreenshotContent), 'unexpected screenshot json');
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can be a bit stronger with our assertions here, maybe that it parses and it has the timestamp property?

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.

Choose a reason for hiding this comment

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

benim sitem çok yavaş : (( bana yardım edermisiniz http://ankaraotokurtarici.com


const fcpTiming = getTiming('ttfcp');
const fmpTiming = getTiming('ttfmp');
const vc100Timing = getTiming('vc100');
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we get 85% too? not sure if it's in pwmetrics yet but we should since we'll be switching up TTI soon enough :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup.

}

/**
* Analyzes the screenshots for the first run of a particular site.
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm I guess the order doesn't really matter then if it's not an aggregation of any sort? I guess we could just pull any random folder huh...sorting just for consistency?

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, it doesn't really matter but it's nice to know it's always the first run when you're looking up the artifacts for a particular run (e.g. open the trace file for a fishy run).

@brendankenny
Copy link
Member

love being able to compare, and the screenshots mode makes this amazing for a very visual look at what's going on. For a major switch (like a site going non-PWA to PWA) or

For example, I can imagine a product manager be very interested in the Aligned Screenshot Timeline View for their company and top 3 competitors.

this will be awesome.

Do you have plans for comparing two distributions of runs, too? I think for more minor changes (as opposed to switching to a totally new TTI) that's going to give a better picture of what's going on than comparing just two runs at a time.

Also did you see #2011? Pretty please :)

@wwwillchen
Copy link
Contributor Author

@brendankenny I have it on my to-do list to create a box plot which will show distributions of runs for a particular site over time (e.g. different lighthouse versions). My sense is that this will be more valuable for the Lighthouse team in the longer-term (i.e. post I/O) when the metrics have settled - but if this is a high priority for the team, I can work on it soon.

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.

Please take another look.

const ssJSONFilename = 'the_file-0.screenshots.json';
const ssFileContents = fs.readFileSync(ssJSONFilename, 'utf8');
const expectedScreenshotContent = '"timestamp": 674089419.919,';
assert.ok(ssFileContents.includes(expectedScreenshotContent), 'unexpected screenshot json');
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.

}

/**
* Analyzes the screenshots for the first run of a particular site.
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, it doesn't really matter but it's nice to know it's always the first run when you're looking up the artifacts for a particular run (e.g. open the trace file for a fishy run).


const fcpTiming = getTiming('ttfcp');
const fmpTiming = getTiming('ttfmp');
const vc100Timing = getTiming('vc100');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup.

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.

a-ok by me

fs.writeFileSync(screenshotsHTMLFilename, data.screenshotsHTML);
log.log('screenshots saved to disk', screenshotsHTMLFilename);

const screenshotsJSONFilename = `${pathWithBasename}-${index}.screenshots.json`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

make sure to add this to gitignore too :)

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

$ node analyze.js -a ../out-first -b ../out-second

# Use the screenshot viewer
# Open index.html in browser
Copy link
Collaborator

Choose a reason for hiding this comment

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

would be dope to use opn and have analyze just open the graphs once it's done :)

@wwwillchen
Copy link
Contributor Author

Re-opening PR to retrigger Travis job

@wwwillchen wwwillchen closed this Apr 20, 2017
@wwwillchen wwwillchen reopened this Apr 20, 2017
Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

awesome stuff. I gave you a PR with a few more goodies that really makes this feature pretty hot:
wwwillchen#1

with that and the other stuff in here sorted, i'm feelin p good!

* lighthouse can affect perf results in real-world sites.
*
* Example usage:
* node analyze.js -a ./out-first -b ./out-second
Copy link
Member

Choose a reason for hiding this comment

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

i'm thinking there is also the usecase of...

i want to compare two traces that were captured in the same measure run.

so like:

node analyze -a ./out/www.espn.com-./0/  -b ./out/www.espn.com-./2/

however I suppose your approach here is to show multiple sites across these two runs.
should we support both ways?
i'm down with whichever.

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 originally didn't think about this use case because then you're comparing two traces with the same configuration (e.g. lighthouse, chrome version) and in that case, I think the end goal could be to either A) visualize the variance between runs when all factors are held constant or B) compare multiple sites (e.g. a PM wants to compare their site vs. 3 competitors).

These seem like nice to have cases but not essential. Let's defer them until later?

Copy link
Member

Choose a reason for hiding this comment

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

Let's defer them until later?

k

* @return {!SingleRunScreenshots}
*/
function analyzeSingleRunScreenshots(sitePath) {
const runDir = sortRunFolders(fs.readdirSync(sitePath))[0];
Copy link
Member

Choose a reason for hiding this comment

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

this readdirSync returned a .DS_Store file which ended up setting runPath to NaN. :)

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oy - fixed!

Choose a reason for hiding this comment

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

Arkadaşlar ben siteme bunu nasıl ekleyebilirim ? http://ankaraotokurtarici.com
Lütfen bana yardım edermisiniz
Help me pls

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 ptal.

fs.writeFileSync(screenshotsHTMLFilename, data.screenshotsHTML);
log.log('screenshots saved to disk', screenshotsHTMLFilename);

const screenshotsJSONFilename = `${pathWithBasename}-${index}.screenshots.json`;
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

* lighthouse can affect perf results in real-world sites.
*
* Example usage:
* node analyze.js -a ./out-first -b ./out-second
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 originally didn't think about this use case because then you're comparing two traces with the same configuration (e.g. lighthouse, chrome version) and in that case, I think the end goal could be to either A) visualize the variance between runs when all factors are held constant or B) compare multiple sites (e.g. a PM wants to compare their site vs. 3 competitors).

These seem like nice to have cases but not essential. Let's defer them until later?

* @return {!SingleRunScreenshots}
*/
function analyzeSingleRunScreenshots(sitePath) {
const runDir = sortRunFolders(fs.readdirSync(sitePath))[0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oy - fixed!

@paulirish
Copy link
Member

@wwwillchen wdyt about wwwillchen#1 ?

plots: add kbd nav, more persistent popover.
@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.

@wwwillchen
Copy link
Contributor Author

@paulirish nice! merged it. Dunno why I didn't see it the first time 😎

@paulirish paulirish merged commit b2eaa08 into GoogleChrome:master Apr 25, 2017
paulirish pushed a commit that referenced this pull request Apr 26, 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.

None yet

6 participants