Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/browser/resources/profiler/profiler.js

Issue 2386123003: Add heap allocator usage to task profiler. (Closed)
Patch Set: Fix remaining clang compile errors. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var g_browserBridge; 5 var g_browserBridge;
6 var g_mainView; 6 var g_mainView;
7 7
8 // TODO(eroman): The handling of "max" across snapshots is not correct. 8 // TODO(eroman): The handling of "max" across snapshots is not correct.
9 // For starters the browser needs to be aware to generate new maximums. 9 // For starters the browser needs to be aware to generate new maximums.
10 // Secondly, we need to take into account the "max" of intermediary snapshots, 10 // Secondly, we need to take into account the "max" of intermediary snapshots,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 var BEGIN_KEY = 1; // Start at 1 rather than 0 to simplify sorting code. 120 var BEGIN_KEY = 1; // Start at 1 rather than 0 to simplify sorting code.
121 var END_KEY = BEGIN_KEY; 121 var END_KEY = BEGIN_KEY;
122 122
123 var KEY_COUNT = END_KEY++; 123 var KEY_COUNT = END_KEY++;
124 var KEY_RUN_TIME = END_KEY++; 124 var KEY_RUN_TIME = END_KEY++;
125 var KEY_AVG_RUN_TIME = END_KEY++; 125 var KEY_AVG_RUN_TIME = END_KEY++;
126 var KEY_MAX_RUN_TIME = END_KEY++; 126 var KEY_MAX_RUN_TIME = END_KEY++;
127 var KEY_QUEUE_TIME = END_KEY++; 127 var KEY_QUEUE_TIME = END_KEY++;
128 var KEY_AVG_QUEUE_TIME = END_KEY++; 128 var KEY_AVG_QUEUE_TIME = END_KEY++;
129 var KEY_MAX_QUEUE_TIME = END_KEY++; 129 var KEY_MAX_QUEUE_TIME = END_KEY++;
130 if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) {
131 var KEY_AVG_ALLOC_OPS = END_KEY++;
132 var KEY_AVG_FREE_OPS = END_KEY++;
133 var KEY_AVG_NET_BYTES = END_KEY++;
134 var KEY_MAX_ALLOCATED_BYTES = END_KEY++;
135 var KEY_ALLOC_OPS = END_KEY++;
136 var KEY_FREE_OPS = END_KEY++;
137 var KEY_ALLOCATED_BYTES = END_KEY++;
138 var KEY_FREED_BYTES = END_KEY++;
139 var KEY_ALLOC_OVERHEAD_BYTES = END_KEY++;
140 }
130 var KEY_BIRTH_THREAD = END_KEY++; 141 var KEY_BIRTH_THREAD = END_KEY++;
131 var KEY_DEATH_THREAD = END_KEY++; 142 var KEY_DEATH_THREAD = END_KEY++;
132 var KEY_PROCESS_TYPE = END_KEY++; 143 var KEY_PROCESS_TYPE = END_KEY++;
133 var KEY_PROCESS_ID = END_KEY++; 144 var KEY_PROCESS_ID = END_KEY++;
134 var KEY_FUNCTION_NAME = END_KEY++; 145 var KEY_FUNCTION_NAME = END_KEY++;
135 var KEY_SOURCE_LOCATION = END_KEY++; 146 var KEY_SOURCE_LOCATION = END_KEY++;
136 var KEY_FILE_NAME = END_KEY++; 147 var KEY_FILE_NAME = END_KEY++;
137 var KEY_LINE_NUMBER = END_KEY++; 148 var KEY_LINE_NUMBER = END_KEY++;
138 149
139 var NUM_KEYS = END_KEY - BEGIN_KEY; 150 var NUM_KEYS = END_KEY - BEGIN_KEY;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return { 247 return {
237 create: function(key) { 248 create: function(key) {
238 return new Aggregator(numeratorKey, divisorKey); 249 return new Aggregator(numeratorKey, divisorKey);
239 }, 250 },
240 }; 251 };
241 } 252 }
242 }; 253 };
243 })(); 254 })();
244 255
245 /** 256 /**
257 * This aggregator computes an average by summing the difference of two
258 * numeric fields, summing a count, and then dividing the totals.
259 */
260 var AvgDiffAggregator = (function() {
261 function Aggregator(numeratorPosKey, numeratorNegKey, divisorKey) {
262 this.numeratorPosKey_ = numeratorPosKey;
263 this.numeratorNegKey_ = numeratorNegKey;
264 this.divisorKey_ = divisorKey;
265
266 this.numeratorSum_ = 0;
267 this.divisorSum_ = 0;
268 }
269
270 Aggregator.prototype = {
271 consume: function(e) {
272 this.numeratorSum_ +=
273 e[this.numeratorPosKey_] - e[this.numeratorNegKey_];
274 this.divisorSum_ += e[this.divisorKey_];
275 },
276
277 getValue: function() {
278 return this.numeratorSum_ / this.divisorSum_;
279 },
280
281 getValueAsText: function() {
282 return formatNumberAsText(this.getValue());
283 },
284 };
285
286 return {
287 create: function(numeratorPosKey, numeratorNegKey, divisorKey) {
288 return {
289 create: function(key) {
290 return new Aggregator(numeratorPosKey, numeratorNegKey, divisorKey);
291 },
292 };
293 }
294 };
295 })();
296
297 /**
246 * This aggregator finds the maximum for a numeric field. 298 * This aggregator finds the maximum for a numeric field.
247 */ 299 */
248 var MaxAggregator = (function() { 300 var MaxAggregator = (function() {
249 function Aggregator(key) { 301 function Aggregator(key) {
250 this.key_ = key; 302 this.key_ = key;
251 this.max_ = -Infinity; 303 this.max_ = -Infinity;
252 } 304 }
253 305
254 Aggregator.prototype = { 306 Aggregator.prototype = {
255 consume: function(e) { 307 consume: function(e) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 KEY_PROPERTIES[KEY_RUN_TIME] = { 463 KEY_PROPERTIES[KEY_RUN_TIME] = {
412 name: 'Total run time', 464 name: 'Total run time',
413 cellAlignment: 'right', 465 cellAlignment: 'right',
414 sortDescending: true, 466 sortDescending: true,
415 textPrinter: formatNumberAsText, 467 textPrinter: formatNumberAsText,
416 inputJsonKey: 'death_data.run_ms', 468 inputJsonKey: 'death_data.run_ms',
417 aggregator: SumAggregator, 469 aggregator: SumAggregator,
418 diff: diffFuncForCount, 470 diff: diffFuncForCount,
419 }; 471 };
420 472
473 if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) {
474 KEY_PROPERTIES[KEY_AVG_ALLOC_OPS] = {
475 name: 'Avg Allocations',
476 cellAlignment: 'right',
477 sortDescending: true,
478 textPrinter: formatNumberAsText,
479 aggregator: AvgAggregator.create(KEY_ALLOC_OPS, KEY_COUNT),
480 };
481
482 KEY_PROPERTIES[KEY_AVG_FREE_OPS] = {
483 name: 'Avg Frees',
484 cellAlignment: 'right',
485 sortDescending: true,
486 textPrinter: formatNumberAsText,
487 aggregator: AvgAggregator.create(KEY_FREE_OPS, KEY_COUNT),
488 };
489
490 KEY_PROPERTIES[KEY_AVG_NET_BYTES] = {
491 name: 'Avg Net Bytes',
492 cellAlignment: 'right',
493 sortDescending: true,
494 textPrinter: formatNumberAsText,
495 aggregator: AvgDiffAggregator.create(KEY_ALLOCATED_BYTES,
496 KEY_FREED_BYTES, KEY_COUNT),
497 };
498
499 KEY_PROPERTIES[KEY_ALLOC_OPS] = {
500 name: 'Allocation count',
501 cellAlignment: 'right',
502 sortDescending: true,
503 textPrinter: formatNumberAsText,
504 inputJsonKey: 'death_data.alloc_ops',
505 aggregator: SumAggregator,
506 diff: diffFuncForCount,
507 };
508
509 KEY_PROPERTIES[KEY_FREE_OPS] = {
510 name: 'Free Count',
511 cellAlignment: 'right',
512 sortDescending: true,
513 textPrinter: formatNumberAsText,
514 inputJsonKey: 'death_data.free_ops',
515 aggregator: SumAggregator,
516 diff: diffFuncForCount,
517 };
518
519 KEY_PROPERTIES[KEY_ALLOCATED_BYTES] = {
520 name: 'Allocated bytes',
521 cellAlignment: 'right',
522 sortDescending: true,
523 textPrinter: formatNumberAsText,
524 inputJsonKey: 'death_data.allocated_bytes',
525 aggregator: SumAggregator,
526 diff: diffFuncForCount,
527 };
528
529 KEY_PROPERTIES[KEY_FREED_BYTES] = {
530 name: 'Freed bytes',
531 cellAlignment: 'right',
532 sortDescending: true,
533 textPrinter: formatNumberAsText,
534 inputJsonKey: 'death_data.freed_bytes',
535 aggregator: SumAggregator,
536 diff: diffFuncForCount,
537 };
538
539 KEY_PROPERTIES[KEY_ALLOC_OVERHEAD_BYTES] = {
540 name: 'Overhead bytes',
541 cellAlignment: 'right',
542 sortDescending: true,
543 textPrinter: formatNumberAsText,
544 inputJsonKey: 'death_data.alloc_overhead_bytes',
545 aggregator: SumAggregator,
546 diff: diffFuncForCount,
547 };
548
549 KEY_PROPERTIES[KEY_MAX_ALLOCATED_BYTES] = {
550 name: 'Max allocated (outstanding) bytes',
551 cellAlignment: 'right',
552 sortDescending: true,
553 textPrinter: formatNumberAsText,
554 inputJsonKey: 'death_data.max_allocated_bytes',
555 aggregator: MaxAggregator,
556 diff: diffFuncForMax,
557 };
558 }
559
421 KEY_PROPERTIES[KEY_AVG_RUN_TIME] = { 560 KEY_PROPERTIES[KEY_AVG_RUN_TIME] = {
422 name: 'Avg run time', 561 name: 'Avg run time',
423 cellAlignment: 'right', 562 cellAlignment: 'right',
424 sortDescending: true, 563 sortDescending: true,
425 textPrinter: formatNumberAsText, 564 textPrinter: formatNumberAsText,
426 aggregator: AvgAggregator.create(KEY_RUN_TIME, KEY_COUNT), 565 aggregator: AvgAggregator.create(KEY_RUN_TIME, KEY_COUNT),
427 }; 566 };
428 567
429 KEY_PROPERTIES[KEY_MAX_RUN_TIME] = { 568 KEY_PROPERTIES[KEY_MAX_RUN_TIME] = {
430 name: 'Max run time', 569 name: 'Max run time',
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 /** 614 /**
476 * List of keys for those properties which we want to initially omit 615 * List of keys for those properties which we want to initially omit
477 * from the table. (They can be re-enabled by clicking [Edit columns]). 616 * from the table. (They can be re-enabled by clicking [Edit columns]).
478 */ 617 */
479 var INITIALLY_HIDDEN_KEYS = [ 618 var INITIALLY_HIDDEN_KEYS = [
480 KEY_FILE_NAME, 619 KEY_FILE_NAME,
481 KEY_LINE_NUMBER, 620 KEY_LINE_NUMBER,
482 KEY_QUEUE_TIME, 621 KEY_QUEUE_TIME,
483 ]; 622 ];
484 623
624 if (loadTimeData.getBoolean('enableMemoryTaskProfiler')) {
625 INITIALLY_HIDDEN_KEYS = INITIALLY_HIDDEN_KEYS.concat([
626 KEY_ALLOC_OPS,
627 KEY_FREE_OPS,
628 KEY_ALLOCATED_BYTES,
629 KEY_FREED_BYTES,
630 KEY_ALLOC_OVERHEAD_BYTES,
631 ]);
632 }
633
485 /** 634 /**
486 * The ordered list of grouping choices to expose in the "Group by" 635 * The ordered list of grouping choices to expose in the "Group by"
487 * dropdowns. We don't include the numeric properties, since they 636 * dropdowns. We don't include the numeric properties, since they
488 * leads to awkward bucketing. 637 * leads to awkward bucketing.
489 */ 638 */
490 var GROUPING_DROPDOWN_CHOICES = [ 639 var GROUPING_DROPDOWN_CHOICES = [
491 KEY_PROCESS_TYPE, 640 KEY_PROCESS_TYPE,
492 KEY_PROCESS_ID, 641 KEY_PROCESS_ID,
493 KEY_BIRTH_THREAD, 642 KEY_BIRTH_THREAD,
494 KEY_DEATH_THREAD, 643 KEY_DEATH_THREAD,
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 groupKey.push(entry); 2352 groupKey.push(entry);
2204 } 2353 }
2205 2354
2206 return JSON.stringify(groupKey); 2355 return JSON.stringify(groupKey);
2207 }; 2356 };
2208 }, 2357 },
2209 }; 2358 };
2210 2359
2211 return MainView; 2360 return MainView;
2212 })(); 2361 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698