perf: tracingModel to computed artifact (#1668)
This commit is contained in:
Родитель
4e660019ec
Коммит
ec5fbe392f
|
@ -44,14 +44,11 @@ class EstimatedInputLatency extends Audit {
|
|||
};
|
||||
}
|
||||
|
||||
static calculate(speedline, trace) {
|
||||
static calculate(speedline, model, trace) {
|
||||
// Use speedline's first paint as start of range for input latency check.
|
||||
const startTime = speedline.first;
|
||||
|
||||
const tracingProcessor = new TracingProcessor();
|
||||
const model = tracingProcessor.init(trace);
|
||||
const latencyPercentiles = TracingProcessor.getRiskToResponsiveness(model, trace, startTime);
|
||||
|
||||
const ninetieth = latencyPercentiles.find(result => result.percentile === 0.9);
|
||||
const rawValue = parseFloat(ninetieth.time.toFixed(1));
|
||||
|
||||
|
@ -86,8 +83,12 @@ class EstimatedInputLatency extends Audit {
|
|||
static audit(artifacts) {
|
||||
const trace = artifacts.traces[this.DEFAULT_PASS];
|
||||
|
||||
return artifacts.requestSpeedline(trace)
|
||||
.then(speedline => EstimatedInputLatency.calculate(speedline, trace));
|
||||
const pending = [
|
||||
artifacts.requestSpeedline(trace),
|
||||
artifacts.requestTracingModel(trace)
|
||||
];
|
||||
return Promise.all(pending).then(([speedline, model]) =>
|
||||
EstimatedInputLatency.calculate(speedline, model, trace));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,20 +63,15 @@ class TTIMetric extends Audit {
|
|||
*/
|
||||
static audit(artifacts) {
|
||||
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
||||
const pendingSpeedline = artifacts.requestSpeedline(trace);
|
||||
const pendingFMP = FMPMetric.audit(artifacts);
|
||||
|
||||
// We start looking at Math.Max(FMPMetric, visProgress[0.85])
|
||||
return Promise.all([pendingSpeedline, pendingFMP]).then(results => {
|
||||
const speedline = results[0];
|
||||
const fmpResult = results[1];
|
||||
|
||||
// Process the trace
|
||||
const tracingProcessor = new TracingProcessor();
|
||||
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
||||
const model = tracingProcessor.init(trace);
|
||||
const pending = [
|
||||
artifacts.requestSpeedline(trace),
|
||||
FMPMetric.audit(artifacts),
|
||||
artifacts.requestTracingModel(trace)
|
||||
];
|
||||
return Promise.all(pending).then(([speedline, fmpResult, model]) => {
|
||||
const endOfTraceTime = model.bounds.max;
|
||||
|
||||
const fmpTiming = fmpResult.rawValue;
|
||||
const fmpResultExt = fmpResult.extendedInfo.value;
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const ComputedArtifact = require('./computed-artifact');
|
||||
const TracingProcessor = require('../../lib/traces/tracing-processor');
|
||||
|
||||
class TracingModel extends ComputedArtifact {
|
||||
|
||||
get name() {
|
||||
return 'TracingModel';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return catapult traceviewer model
|
||||
* @param {{traceEvents: !Array}} trace
|
||||
* @return {!TracingProcessorModel}
|
||||
*/
|
||||
compute_(trace) {
|
||||
const tracingProcessor = new TracingProcessor();
|
||||
return tracingProcessor.init(trace);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = TracingModel;
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const TracingModel = require('../../../gather/computed/tracing-model');
|
||||
|
||||
const assert = require('assert');
|
||||
const pwaTrace = require('../../fixtures/traces/progressive-app.json');
|
||||
|
||||
/* eslint-env mocha */
|
||||
describe('Tracing model computed artifact:', () => {
|
||||
it('gets a tracing model', () => {
|
||||
const tracingModel = new TracingModel();
|
||||
const model = tracingModel.compute_(pwaTrace);
|
||||
assert.ok(model instanceof global.tr.Model, 'return is not an instance of tr.Model');
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче