Use traceviewer package for trace parsing

\o/
This commit is contained in:
Nat Duca 2016-03-07 23:23:15 -08:00
Родитель 9ebb7804ac
Коммит 019b7fa2ef
4 изменённых файлов: 3 добавлений и 130 удалений

Просмотреть файл

@ -1,79 +0,0 @@
/**
* @license
* Copyright 2015 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.
*/
function enable () {
// Sets some global options so that the trace viewer code can work.
// It expects to be run inside of a browser, where host objects
// (and Polymer) exist. Since they don't they need stubbing out.
global.Polymer = function () {};
global.Polymer.elements = {};
global.HTMLUnknownElement = {};
global.HTMLDivElement = {};
global.document = {
currentScript: {
ownerDocument: {}
},
createElement: function () {
return {
style: {
}
};
}
};
global.vec2 = {create: function () {}, set: function () {}};
global.vec3 = {create: function () {}};
global.vec4 = {create: function () {}};
global.mat2d = {create: function () {}};
global.mat4 = {create: function () {}};
global.window = {
performance: {
now: function () {
return Date.now();
}
}, webkitRequestAnimationFrame: function (cb) {
cb();
}, requestAnimationFrame: function (cb) {
cb();
}
};
}
function disable () {
delete global.Polymer.elements;
delete global.Polymer;
delete global.HTMLUnknownElement;
delete global.HTMLDivElement;
delete global.document;
delete global.vec2;
delete global.vec3;
delete global.vec4;
delete global.mat2d;
delete global.mat4;
delete global.window;
}
module.exports = {
enable: enable,
disable: disable
};

Просмотреть файл

@ -17,16 +17,13 @@
/* global tr */
var traceviewer = require('traceviewer');
var URL = require('url');
var RESPONSE = 'Response';
var ANIMATION = 'Animation';
var LOAD = 'Load';
// Does a bunch on the global object, because the code for trace viewer
// currently operates on `window`, and the conversion doesn't account for
// requires and modules.
var globalConfig = require('./global-config.js');
function analyzeTrace (contents, opts) {
var contentsJSON = null;
@ -50,8 +47,6 @@ function analyzeTrace (contents, opts) {
})];
// Switch on all the globals we need, and import tracing.
globalConfig.enable();
var model = convertEventsToModel(events);
var processes = model.getAllProcesses();
var traceProcess = null;
@ -97,22 +92,12 @@ function analyzeTrace (contents, opts) {
}
traceProcess = summarizable.pop();
// Reset all the globals we had to define for window etc.
globalConfig.disable();
return processTrace(model, traceProcess, opts);
}
function convertEventsToModel (events) {
require('./third_party/tracing/importer/import.js');
require('./third_party/tracing/extras/importer/trace_event_importer.js');
require('./third_party/tracing/extras/rail/rail_score.js');
require('./third_party/tracing/extras/rail/rail_ir_finder.js');
require('./tracing-config.js');
var io = new tr.importer.ImportOptions();
io.showImportWarnings = false;
io.shiftWorldToZero = true;
io.pruneEmptyContainers = false;
var model = new tr.Model();

Просмотреть файл

@ -1,34 +0,0 @@
/**
* @license
* Copyright 2015 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.
*/
/* global tr */
// Sets up a few stubs for tracing, particularly for the HTML Elements it
// expects to exist, which won't because this is running in Node.
tr.isHeadless = false;
tr.ui.b.Overlay = function () {
return {
title: '',
msgEl: {
style: {
margin: ''
}
},
appendChild: function () {
}
};
};

Просмотреть файл

@ -24,6 +24,7 @@
"cheerio": "^0.19.0",
"file": "^0.2.2",
"selenium-webdriver": "^2.48.2",
"traceviewer": "^1.0.8",
"walk": "^2.3.9"
},
"devDependencies": {