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

Side by Side Diff: tracing/tracing/metrics/cpu_process_metric.html

Issue 2283213002: Rename Histogram.add() to addSample(). (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 years, 3 months 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/metrics/metric_registry.html"> 8 <link rel="import" href="/tracing/metrics/metric_registry.html">
9 <link rel="import" href="/tracing/value/histogram.html"> 9 <link rel="import" href="/tracing/value/histogram.html">
10 <link rel="import" href="/tracing/value/value.html"> 10 <link rel="import" href="/tracing/value/value.html">
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 for (var snapshot of snapshots) { 46 for (var snapshot of snapshots) {
47 var processSums = getProcessSumsFromSnapshot(snapshot); 47 var processSums = getProcessSumsFromSnapshot(snapshot);
48 for (var [processName, processData] of processSums.entries()) { 48 for (var [processName, processData] of processSums.entries()) {
49 if (!(processNumerics.has(processName))) { 49 if (!(processNumerics.has(processName))) {
50 processNumerics.set(processName, { 50 processNumerics.set(processName, {
51 numeric: new tr.v.Histogram( 51 numeric: new tr.v.Histogram(
52 tr.v.Unit.byName.normalizedPercentage_smallerIsBetter), 52 tr.v.Unit.byName.normalizedPercentage_smallerIsBetter),
53 paths: new Set() 53 paths: new Set()
54 }); 54 });
55 } 55 }
56 processNumerics.get(processName).numeric.add( 56 processNumerics.get(processName).numeric.addSample(
57 processData.sum / 100.0); 57 processData.sum / 100.0);
58 for (var path of processData.paths) 58 for (var path of processData.paths)
59 processNumerics.get(processName).paths.add(path); 59 processNumerics.get(processName).paths.add(path);
60 } 60 }
61 } 61 }
62 return processNumerics; 62 return processNumerics;
63 } 63 }
64 64
65 function cpuProcessMetric(values, model) { 65 function cpuProcessMetric(values, model) {
66 var snapshots = getCpuSnapshotsFromModel(model); 66 var snapshots = getCpuSnapshotsFromModel(model);
67 var processNumerics = buildNumericsFromSnapshots(snapshots); 67 var processNumerics = buildNumericsFromSnapshots(snapshots);
68 for (var [processName, processData] of processNumerics.entries()) { 68 for (var [processName, processData] of processNumerics.entries()) {
69 var numeric = processData.numeric; 69 var numeric = processData.numeric;
70 // Treat missing snapshots as zeros. A process is missing from a snapshots 70 // Treat missing snapshots as zeros. A process is missing from a snapshots
71 // when its CPU usage was below minimum threshold when the snapshot was 71 // when its CPU usage was below minimum threshold when the snapshot was
72 // taken. 72 // taken.
73 var missingSnapshotCount = snapshots.length - numeric.numValues; 73 var missingSnapshotCount = snapshots.length - numeric.numValues;
74 for (var i = 0; i < missingSnapshotCount; i++) 74 for (var i = 0; i < missingSnapshotCount; i++)
75 numeric.add(0); 75 numeric.addSample(0);
76 var value = new tr.v.NumericValue('cpu:percent:' + processName, numeric); 76 var value = new tr.v.NumericValue('cpu:percent:' + processName, numeric);
77 value.diagnostics.set('paths', new 77 value.diagnostics.set('paths', new
78 tr.v.d.Generic([...processData.paths])); 78 tr.v.d.Generic([...processData.paths]));
79 values.addValue(value); 79 values.addValue(value);
80 } 80 }
81 } 81 }
82 82
83 tr.metrics.MetricRegistry.register(cpuProcessMetric); 83 tr.metrics.MetricRegistry.register(cpuProcessMetric);
84 84
85 return { 85 return {
86 cpuProcessMetric: cpuProcessMetric 86 cpuProcessMetric: cpuProcessMetric
87 }; 87 };
88 }); 88 });
89 </script> 89 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/blink/gc_metric.html ('k') | tracing/tracing/metrics/metric_registry_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698