core(predictive-perf): refactor simulation logic#3489
Conversation
paulirish
left a comment
There was a problem hiding this comment.
this works for me! only one small nit
| */ | ||
| simulateDownloadUntil(bytesToDownload, timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity) { | ||
| simulateDownloadUntil(bytesToDownload, options) { | ||
| options = Object.assign({ |
There was a problem hiding this comment.
can we destructure AND do default values?
based on http://node.green/ i think we're good.
|
@brendankenny did you want a whack at this too, or you good? |
brendankenny
left a comment
There was a problem hiding this comment.
just a few style nits but otherwise LGTM
| Object.keys(graphs).forEach(key => { | ||
| const estimate = PageDependencyGraph.estimateGraph(graphs[key]); | ||
| const lastLongTaskEnd = PredictivePerf.getLastLongTaskEndTime(estimate.nodeTiming); | ||
| const results = new Simulator(graphs[key]).simulate(); |
There was a problem hiding this comment.
I'd personally still prefer estimate for the local var here, as results is information-less :) or simulatedResults or something. results could be anything
| const Util = require('../report/v2/renderer/util.js'); | ||
| const PageDependencyGraph = require('../gather/computed/page-dependency-graph.js'); | ||
| const Node = require('../gather/computed/dependency-graph/node.js'); | ||
| const Simulator = require('../lib/dependency-graph/simulator/simulator.js'); |
There was a problem hiding this comment.
I guess simulator.js's context can be figured out from its path, but maybe LoadSimulator or something for the local handle to it?
| this._connectionsInUse = new Set(); | ||
| this._numberInProgressByType = new Map(); | ||
|
|
||
| this._nodes = {}; |
There was a problem hiding this comment.
should be an array now?
There was a problem hiding this comment.
wait why? I thought the whole point was to key these by their state 😆
EDIT: oh just that the keys are numbers now so you'd prefer to have array?
There was a problem hiding this comment.
EDIT: oh just that the keys are numbers now so you'd prefer to have array?
yah
| node.record.transferSize - timingData.bytesDownloaded, | ||
| timingData.timeElapsed, | ||
| timePeriodLength - timingData.timeElapsedOvershoot | ||
| { |
There was a problem hiding this comment.
wait, why is this moving to an options object? There's only three and having them named doesn't seem better in this case...
There was a problem hiding this comment.
I feel ya @brendankenny, but @paulirish was persistent
executive summary: it's easier for the caller to understand what the params are
|
rebase to pick up test fixes? |
* Moves gather/computed/dependency-graph to lib/dependency-graph * Renames estimator -> simulator * Eliminates estimateGraph method from PageDependencyGraph artifact class * Renames the node states in Simulator * Refactors signature of simulateDownloadUntil
fdd4f64 to
1895a8d
Compare
Addresses the remaining non-accuracy impacting items from code review.
TODO from #3162 (comment) (Separately with analysis of impact to accuracy)
isValidDepGraph