OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "base/task_scheduler/task_tracker.h" | 5 #include "base/task_scheduler/task_tracker.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 out->append(tmp); | 67 out->append(tmp); |
68 } | 68 } |
69 | 69 |
70 const char kQueueFunctionName[] = "base::PostTask"; | 70 const char kQueueFunctionName[] = "base::PostTask"; |
71 | 71 |
72 // This name conveys that a Task is run by the task scheduler without revealing | 72 // This name conveys that a Task is run by the task scheduler without revealing |
73 // its implementation details. | 73 // its implementation details. |
74 const char kRunFunctionName[] = "TaskSchedulerRunTask"; | 74 const char kRunFunctionName[] = "TaskSchedulerRunTask"; |
75 | 75 |
76 HistogramBase* GetTaskLatencyHistogram(const char* suffix) { | 76 HistogramBase* GetTaskLatencyHistogram(const char* suffix) { |
77 // Mimics the UMA_HISTOGRAM_TIMES macro. | 77 // Mimics the UMA_HISTOGRAM_TIMES macro except we don't specify bounds with |
78 return Histogram::FactoryTimeGet( | 78 // TimeDeltas as FactoryTimeGet assumes millisecond granularity. The minimums |
79 std::string("TaskScheduler.TaskLatency.") + suffix, | 79 // and maximums were chosen to place the 1ms mark at around the 70% range |
80 TimeDelta::FromMilliseconds(1), TimeDelta::FromSeconds(10), 50, | 80 // coverage for buckets giving us good info for tasks that have a latency |
81 HistogramBase::kUmaTargetedHistogramFlag); | 81 // below 1ms (most of them) and enough info to assess how bad the latency is |
| 82 // for tasks that exceed this threshold. |
| 83 return Histogram::FactoryGet( |
| 84 std::string("TaskScheduler.TaskLatencyMicroseconds.") + suffix, 1, 20000, |
| 85 50, HistogramBase::kUmaTargetedHistogramFlag); |
82 } | 86 } |
83 | 87 |
84 // Upper bound for the | 88 // Upper bound for the |
85 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. | 89 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. |
86 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000; | 90 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000; |
87 | 91 |
88 void RecordNumBlockShutdownTasksPostedDuringShutdown( | 92 void RecordNumBlockShutdownTasksPostedDuringShutdown( |
89 HistogramBase::Sample value) { | 93 HistogramBase::Sample value) { |
90 UMA_HISTOGRAM_CUSTOM_COUNTS( | 94 UMA_HISTOGRAM_CUSTOM_COUNTS( |
91 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1, | 95 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1, |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 } | 492 } |
489 } | 493 } |
490 | 494 |
491 void TaskTracker::RecordTaskLatencyHistogram(Task* task) { | 495 void TaskTracker::RecordTaskLatencyHistogram(Task* task) { |
492 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; | 496 const TimeDelta task_latency = TimeTicks::Now() - task->sequenced_time; |
493 task_latency_histograms_[static_cast<int>(task->traits.priority())] | 497 task_latency_histograms_[static_cast<int>(task->traits.priority())] |
494 [task->traits.may_block() || | 498 [task->traits.may_block() || |
495 task->traits.with_base_sync_primitives() | 499 task->traits.with_base_sync_primitives() |
496 ? 1 | 500 ? 1 |
497 : 0] | 501 : 0] |
498 ->AddTime(task_latency); | 502 ->Add(task_latency.InMicroseconds()); |
499 } | 503 } |
500 | 504 |
501 } // namespace internal | 505 } // namespace internal |
502 } // namespace base | 506 } // namespace base |
OLD | NEW |