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

move computed artifacts dependent on networkRecords to devtoolsLog #2467

Merged
merged 5 commits into from
Jun 8, 2017

Conversation

brendankenny
Copy link
Member

followup to #2062 and #2133 (specifically #2062 (comment))

really just a convenience thing. Since computed artifacts can request other computed artifacts, callers of e.g. criticalRequestChains shouldn't have to construct networkRecords, CRC can just do it itself.

artifacts.requestNetworkRecords(devtoolsLogs),
artifacts.requestNetworkThroughput(devtoolsLogs)
]).then(([networkRecords, networkThroughput]) => {
let totalBytes = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

the changes here (and in critical-request-chains.js) are just indentation (and, sadly, just reversing the indenting #2062 did :P)

@@ -26,8 +26,6 @@ describe('NetworkThroughput', () => {
}

it('should return Infinity for no/missing records', () => {
assert.equal(compute(undefined), Infinity);
assert.equal(compute(null), Infinity);
Copy link
Member Author

Choose a reason for hiding this comment

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

since the network records will now always come from requestNetworkRecords, there will always be some array, so these aren't necessary anymore. I may be missing a failure mode, though, because I don't remember how these were possible in the first place. Please clue me in if I am missing something :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think I expected them to be null, probably just overly defensive

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.

I won't go so far as to say "Request changes" but I'm not a fan of spreading the influence of instatiateComputedArtifacts haha :)

const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
return artifacts.requestNetworkRecords(devtoolsLog)
.then(networkRecords => this.audit_(artifacts, networkRecords))
.then(result => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this restructuring seems unnecessary just trying to remove nesting?

Copy link
Member Author

Choose a reason for hiding this comment

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

just trying to remove nesting?

yeah, and it gets rid of the Promise.resolve. I tried a few different permutations and this was a less awkward version than others, but I can revert to

return artifacts.requestNetworkRecords(devtoolsLogs).then(networkRecords => {
  return artifacts.requestNetworkThroughput(devtoolsLogs).then(networkThroughput =>
    Promise.resolve(this.audit_(artifacts, networkRecords)).then(result =>
      this.createAuditResult(result, networkThroughput)
    )
  );
});

if you want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

eh not a big deal, this is fine

Copy link
Member Author

Choose a reason for hiding this comment

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

awkwardness like this due to needing to hold onto variables will be a lot better once we can use async/await

const assert = require('assert');
const Gatherer = new GathererClass();

const Runner = require('../../../runner.js');
Copy link
Collaborator

Choose a reason for hiding this comment

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

well that's annoying, can't we just pass an obj like {requestNetworkRecords: () =>...} to compute_ instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

these tests are already cheating by assuming the exact properties of network requests the gatherer will need, so that's probably fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. Also added one test that does the end to end devtoolsLog -> CRC extraction

@@ -26,8 +26,6 @@ describe('NetworkThroughput', () => {
}

it('should return Infinity for no/missing records', () => {
assert.equal(compute(undefined), Infinity);
assert.equal(compute(null), Infinity);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think I expected them to be null, probably just overly defensive

@@ -7,15 +7,17 @@

/* eslint-env mocha */

const GathererClass = require('../../../gather/computed/pushed-requests');
const Runner = require('../../../runner.js');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Member Author

Choose a reason for hiding this comment

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

I can update this one too, but I don't even know why we have this gatherer and really am tempted to just delete it :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

🗑 ⬅️ ⚾️ 💨 💪

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, so I'll wait until Paul gets back to delete, but also don't care enough to update :)

I think it's fine with instatiateComputedArtifacts, and it's annoying enough to recreate that network record in a devtoolsLog (that site doesn't appear to be using http2 push anymore?) that mocking requestNetworkRecords doesn't seem like the worrrrst thing.

wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah cool with me

@brendankenny brendankenny merged commit d59fd6d into master Jun 8, 2017
@brendankenny brendankenny deleted the requestnet branch June 8, 2017 22:46
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.

2 participants