1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 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/model/timed_event.html"> 9<link rel="import" href="/tracing/value/unit.html"> 10 11<script> 12'use strict'; 13 14/** 15 * @fileoverview Provides the Sample class. 16 */ 17tr.exportTo('tr.model', function() { 18 /** 19 * A Sample represents a sample taken at an instant in time, plus its stack 20 * frame and parameters associated with that sample. 21 * 22 * @constructor 23 */ 24 function Sample(cpu, thread, title, start, leafStackFrame, 25 opt_weight, opt_args) { 26 tr.model.TimedEvent.call(this, start); 27 28 this.title = title; 29 this.cpu = cpu; 30 this.thread = thread; 31 this.leafStackFrame = leafStackFrame; 32 this.weight = opt_weight; 33 this.args = opt_args || {}; 34 } 35 36 Sample.prototype = { 37 __proto__: tr.model.TimedEvent.prototype, 38 39 get colorId() { 40 return this.leafStackFrame.colorId; 41 }, 42 43 get stackTrace() { 44 return this.leafStackFrame.stackTrace; 45 }, 46 47 getUserFriendlyStackTrace: function() { 48 return this.leafStackFrame.getUserFriendlyStackTrace(); 49 }, 50 51 get userFriendlyName() { 52 return 'Sample at ' + tr.v.Unit.byName.timeStampInMs.format(this.start); 53 } 54 }; 55 56 tr.model.EventRegistry.register( 57 Sample, 58 { 59 name: 'sample', 60 pluralName: 'samples', 61 singleViewElementName: 'tr-ui-a-single-sample-sub-view', 62 multiViewElementName: 'tr-ui-a-multi-sample-sub-view' 63 }); 64 65 return { 66 Sample: Sample 67 }; 68}); 69</script> 70 71