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: tracing/tracing/metrics/system_health/cpu_time_metric.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 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/model/helpers/chrome_model_helper.html"> 9 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html">
10 <link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html"> 10 <link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html">
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 var processCpuTime = 0; 60 var processCpuTime = 0;
61 for (var tid in process.threads) { 61 for (var tid in process.threads) {
62 var thread = process.threads[tid]; 62 var thread = process.threads[tid];
63 var threadCpuTime = 0; 63 var threadCpuTime = 0;
64 thread.sliceGroup.topLevelSlices.forEach(function(slice) { 64 thread.sliceGroup.topLevelSlices.forEach(function(slice) {
65 if (slice.duration === 0) 65 if (slice.duration === 0)
66 return; 66 return;
67 if (!slice.cpuDuration) 67 if (!slice.cpuDuration)
68 return; 68 return;
69 var sliceRange = tr.b.Range.fromExplicitRange(slice.start, slice.end); 69 var sliceRange = tr.b.math.Range.fromExplicitRange(
70 slice.start, slice.end);
70 var intersection = rangeOfInterest.findIntersection(sliceRange); 71 var intersection = rangeOfInterest.findIntersection(sliceRange);
71 var fractionOfSliceInsideRangeOfInterest = 72 var fractionOfSliceInsideRangeOfInterest =
72 intersection.duration / slice.duration; 73 intersection.duration / slice.duration;
73 74
74 // We assume that if a slice doesn't lie entirely inside the range of 75 // We assume that if a slice doesn't lie entirely inside the range of
75 // interest, then the CPU time is evenly distributed inside of the 76 // interest, then the CPU time is evenly distributed inside of the
76 // slice. 77 // slice.
77 threadCpuTime += 78 threadCpuTime +=
78 slice.cpuDuration * fractionOfSliceInsideRangeOfInterest; 79 slice.cpuDuration * fractionOfSliceInsideRangeOfInterest;
79 }); 80 });
(...skipping 29 matching lines...) Expand all
109 110
110 tr.metrics.MetricRegistry.register(cpuTimeMetric, { 111 tr.metrics.MetricRegistry.register(cpuTimeMetric, {
111 supportsRangeOfInterest: true 112 supportsRangeOfInterest: true
112 }); 113 });
113 114
114 return { 115 return {
115 cpuTimeMetric, 116 cpuTimeMetric,
116 }; 117 };
117 }); 118 });
118 </script> 119 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/spa_navigation_metric.html ('k') | tracing/tracing/metrics/system_health/cpu_time_metric_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698