1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * @fileoverview Provides the Process class.
10 tvcm.require('tracing.trace_model.cpu');
11 tvcm.require('tracing.trace_model.process_base');
12 tvcm.require('tvcm.iteration_helpers');
14 tvcm.exportTo('tracing.trace_model', function() {
16 var Cpu = tracing.trace_model.Cpu;
17 var ProcessBase = tracing.trace_model.ProcessBase;
20 * The Kernel represents kernel-level objects in the
24 function Kernel(model) {
25 if (model === undefined)
26 throw new Error('model must be provided');
27 ProcessBase.call(this, model);
29 this.softwareMeasuredCpuCount_ = undefined;
33 * Comparison between kernels is pretty meaningless.
35 Kernel.compare = function(x, y) {
40 __proto__: ProcessBase.prototype,
42 compareTo: function(that) {
43 return Kernel.compare(this, that);
46 get userFriendlyName() {
50 get userFriendlyDetails() {
55 * @return {Cpu} Gets a specific Cpu or creates one if
58 getOrCreateCpu: function(cpuNumber) {
59 if (!this.cpus[cpuNumber])
60 this.cpus[cpuNumber] = new Cpu(this, cpuNumber);
61 return this.cpus[cpuNumber];
64 get softwareMeasuredCpuCount() {
65 return this.softwareMeasuredCpuCount_;
68 set softwareMeasuredCpuCount(softwareMeasuredCpuCount) {
69 if (this.softwareMeasuredCpuCount_ !== undefined &&
70 this.softwareMeasuredCpuCount_ !== softwareMeasuredCpuCount) {
72 'Cannot change the softwareMeasuredCpuCount once it is set');
75 this.softwareMeasuredCpuCount_ = softwareMeasuredCpuCount;
79 * Estimates how many cpus are in the system, for use in system load
82 * If kernel trace was provided, uses that data. Otherwise, uses the
83 * software measured cpu count.
85 get bestGuessAtCpuCount() {
86 var realCpuCount = tvcm.dictionaryLength(this.cpus);
87 if (realCpuCount !== 0)
89 return this.softwareMeasuredCpuCount;
92 shiftTimestampsForward: function(amount) {
93 ProcessBase.prototype.shiftTimestampsForward.call(this);
94 for (var cpuNumber in this.cpus)
95 this.cpus[cpuNumber].shiftTimestampsForward(amount);
98 updateBounds: function() {
99 ProcessBase.prototype.updateBounds.call(this);
100 for (var cpuNumber in this.cpus) {
101 var cpu = this.cpus[cpuNumber];
103 this.bounds.addRange(cpu.bounds);
107 createSubSlices: function() {
108 ProcessBase.prototype.createSubSlices.call(this);
109 for (var cpuNumber in this.cpus) {
110 var cpu = this.cpus[cpuNumber];
111 cpu.createSubSlices();
115 addCategoriesToDict: function(categoriesDict) {
116 ProcessBase.prototype.addCategoriesToDict.call(this, categoriesDict);
117 for (var cpuNumber in this.cpus)
118 this.cpus[cpuNumber].addCategoriesToDict(categoriesDict);
121 getSettingsKey: function() {
125 iterateAllEvents: function(callback, opt_this) {
126 for (var cpuNumber in this.cpus)
127 this.cpus[cpuNumber].iterateAllEvents(callback, opt_this);
129 ProcessBase.prototype.iterateAllEvents.call(this, callback, opt_this);