diff options
author | Klaas Boesche <klaasb@google.com> | 2015-10-02 16:50:57 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2015-10-02 18:02:49 +0000 |
commit | 1e62b6b61487f7dd37e6747ab88ab16405095b3e (patch) | |
tree | b19f430f3db8d3f8664212c106406fe9b2d7ebf4 /src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java | |
parent | 23c725b6824e7beac753779a5abeeb44c9be3bda (diff) |
Add --task_tree and --task_tree_threshold options.
Options allow displaying some tasks in more detail, e.g. for inspecting what
exactly a Skylark user-defined function calls and how long that takes.
--
MOS_MIGRATED_REVID=104505599
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java b/src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java index 1a422db914..72afab45bf 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/statistics/TasksStatistics.java @@ -13,10 +13,9 @@ // limitations under the License. package com.google.devtools.build.lib.profiler.statistics; +import com.google.devtools.build.lib.profiler.ProfileInfo; import com.google.devtools.build.lib.profiler.ProfileInfo.Task; -import java.util.Collections; -import java.util.Comparator; import java.util.List; /** @@ -91,28 +90,19 @@ public class TasksStatistics { } /** - * @param name - * @param tasks * @return The set of statistics grouped in this class, computed from a list of {@link Task}s. */ public static TasksStatistics create(String name, List<Task> tasks) { - Collections.sort( - tasks, - new Comparator<Task>() { - @Override - public int compare(Task o1, Task o2) { - return Long.compare(o1.duration, o2.duration); - } - }); + tasks = ProfileInfo.TASK_DURATION_ORDERING.immutableSortedCopy(tasks); int count = tasks.size(); - long min = tasks.get(0).duration; - long max = tasks.get(count - 1).duration; + long min = tasks.get(0).durationNanos; + long max = tasks.get(count - 1).durationNanos; int midIndex = count / 2; double median = tasks.size() % 2 == 0 - ? (tasks.get(midIndex).duration + tasks.get(midIndex - 1).duration) / 2.0 - : tasks.get(midIndex).duration; + ? (tasks.get(midIndex).durationNanos + tasks.get(midIndex - 1).durationNanos) / 2.0 + : tasks.get(midIndex).durationNanos; // Compute standard deviation with a shift to avoid catastrophic cancellation // and also do it in milliseconds, as in nanoseconds it overflows @@ -122,9 +112,9 @@ public class TasksStatistics { final long shift = min; for (Task task : tasks) { - sum += task.duration; - self += task.duration - task.getInheritedDuration(); - double taskDurationShiftMillis = toMilliSeconds(task.duration - shift); + sum += task.durationNanos; + self += task.durationNanos - task.getInheritedDuration(); + double taskDurationShiftMillis = toMilliSeconds(task.durationNanos - shift); sumOfSquaredShiftedMillis += taskDurationShiftMillis * taskDurationShiftMillis; } double sumShiftedMillis = toMilliSeconds(sum - count * shift); |