| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/base/range.html"> |
| <link rel="import" href="/model/thread_time_slice.html"> |
| |
| <script> |
| 'use strict'; |
| |
| /** |
| * @fileoverview Provides the CpuSlice class. |
| */ |
| tr.exportTo('tr.model', function() { |
| |
| var Slice = tr.model.Slice; |
| |
| /** |
| * A CpuSlice represents a slice of time on a CPU. |
| * |
| * @constructor |
| */ |
| function CpuSlice(cat, title, colorId, start, args, opt_duration) { |
| Slice.apply(this, arguments); |
| this.threadThatWasRunning = undefined; |
| this.cpu = undefined; |
| } |
| |
| CpuSlice.prototype = { |
| __proto__: Slice.prototype, |
| |
| get analysisTypeName() { |
| return 'tr.c.analysis.CpuSlice'; |
| }, |
| |
| getAssociatedTimeslice: function() { |
| if (!this.threadThatWasRunning) |
| return undefined; |
| var timeSlices = this.threadThatWasRunning.timeSlices; |
| for (var i = 0; i < timeSlices.length; i++) { |
| var timeSlice = timeSlices[i]; |
| if (timeSlice.start !== this.start) |
| continue; |
| if (timeSlice.duration !== this.duration) |
| continue; |
| return timeSlice; |
| } |
| return undefined; |
| } |
| }; |
| |
| tr.model.EventRegistry.register( |
| CpuSlice, |
| { |
| name: 'cpuSlice', |
| pluralName: 'cpuSlices', |
| singleViewElementName: 'tr-c-a-single-cpu-slice-sub-view', |
| multiViewElementName: 'tr-c-a-multi-cpu-slice-sub-view' |
| }); |
| |
| return { |
| CpuSlice: CpuSlice |
| }; |
| }); |
| </script> |