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

Unified Diff: tracing/tracing/extras/chrome/cpu_time.html

Issue 2798213002: Add function to get total cpu time in thread (Closed)
Patch Set: Change bounds to range Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tracing/tracing/extras/chrome/cpu_time_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/extras/chrome/cpu_time.html
diff --git a/tracing/tracing/extras/chrome/cpu_time.html b/tracing/tracing/extras/chrome/cpu_time.html
new file mode 100644
index 0000000000000000000000000000000000000000..341e75c7e3ff206238f57e87d6d1f2865629cf14
--- /dev/null
+++ b/tracing/tracing/extras/chrome/cpu_time.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<!--
+Copyright 2017 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="/tracing/base/multi_dimensional_view.html">
+<link rel="import" href="/tracing/model/helpers/chrome_model_helper.html">
+<link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html">
+
+<script>
+'use strict';
+
+tr.exportTo('tr.e.chrome.cpuTime', function() {
+ /**
+ * Returns the total cpu time consumed within |range| by |thread|.
+ */
+ function getCpuTimeForThread(thread, range) {
+ let totalCpuTime = 0;
+ tr.b.math.iterateOverIntersectingIntervals(
+ thread.sliceGroup.topLevelSlices,
+ slice => slice.start, slice => slice.end,
+ range.min, range.max,
+ slice => {
+ if (slice.duration === 0) return;
+ if (!slice.cpuDuration) return;
+
+ const intersection = range.findIntersection(slice.range);
+ const fractionOfSliceInsideRangeOfInterest =
+ intersection.duration / slice.duration;
+
+ // We assume that if a slice doesn't lie entirely inside the range of
+ // interest, then the CPU time is evenly distributed inside of the
+ // slice.
+ totalCpuTime +=
+ slice.cpuDuration * fractionOfSliceInsideRangeOfInterest;
+ });
+
+ return totalCpuTime;
+ }
+
+ return {
+ getCpuTimeForThread,
+ };
+});
+</script>
« no previous file with comments | « no previous file | tracing/tracing/extras/chrome/cpu_time_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698