1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/base/base.html"> 9<link rel="import" href="/tracing/base/iteration_helpers.html"> 10<link rel="import" href="/tracing/base/xhr.html"> 11<link rel="import" href="/tracing/ui/extras/deep_reports/scalar_value.html"> 12 13<script> 14'use strict'; 15 16tr.exportTo('tr.ui.e.deep_reports', function() { 17 /** 18 * Runs deep reports on the provided files, and pushes telemetry-style 19 * values to the results object. 20 */ 21 function main(results, filesInDir) { 22 var lastP = new Promise(function(resolve) { resolve(); }); 23 24 filesInDir.forEach(function(filename) { 25 // TODO(nduca): Make this like telemetry page. 26 var page = { 27 url: filename 28 }; 29 lastP = lastP.then(function() { 30 return loadModelFromFileAsync(filename); 31 }); 32 lastP = lastP.then(function(model) { 33 processModel(results, page, model); 34 }); 35 }); 36 return lastP; 37 } 38 39 function loadModelFromFileAsync(filename) { 40 return tr.b.getAsync(filename).then(function(trace) { 41 var io = new tr.ImportOptions(); 42 io.shiftWorldToZero = true; 43 io.pruneEmptyContainers = false; 44 45 var m = new tr.Model(); 46 try { 47 m.importTraces([trace], io); 48 } catch (e) { 49 throw new Error('While loading ' + filename + ' got: ' + e.toString()); 50 } 51 return m; 52 }); 53 } 54 55 function processModel(results, page, model) { 56 results.addValue( 57 new tr.ui.e.deep_reports.ScalarValue( 58 page, 'numRailIRs', 'ms', model.userModel.expectations.length)); 59 } 60 61 return { 62 main: main 63 }; 64}); 65</script> 66