OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_TRACKED_OBJECTS_H_ | 5 #ifndef BASE_TRACKED_OBJECTS_H_ |
6 #define BASE_TRACKED_OBJECTS_H_ | 6 #define BASE_TRACKED_OBJECTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <stack> | 10 #include <stack> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // TODO(jar): We can implement a Snapshot system that *tries* to grab the | 157 // TODO(jar): We can implement a Snapshot system that *tries* to grab the |
158 // snapshots on the source threads *when* they have MessageLoops available | 158 // snapshots on the source threads *when* they have MessageLoops available |
159 // (worker threads don't have message loops generally, and hence gathering from | 159 // (worker threads don't have message loops generally, and hence gathering from |
160 // them will continue to be asynchronous). We had an implementation of this in | 160 // them will continue to be asynchronous). We had an implementation of this in |
161 // the past, but the difficulty is dealing with message loops being terminated. | 161 // the past, but the difficulty is dealing with message loops being terminated. |
162 // We can *try* to spam the available threads via some message loop proxy to | 162 // We can *try* to spam the available threads via some message loop proxy to |
163 // achieve this feat, and it *might* be valuable when we are colecting data for | 163 // achieve this feat, and it *might* be valuable when we are colecting data for |
164 // upload via UMA (where correctness of data may be more significant than for a | 164 // upload via UMA (where correctness of data may be more significant than for a |
165 // single screen of about:profiler). | 165 // single screen of about:profiler). |
166 // | 166 // |
167 // TODO(jar): We need to save a single sample in each DeathData instance of the | |
168 // times recorded. This sample should be selected in a uniformly random way. | |
169 // | |
170 // TODO(jar): We should support (optionally) the recording of parent-child | 167 // TODO(jar): We should support (optionally) the recording of parent-child |
171 // relationships for tasks. This should be done by detecting what tasks are | 168 // relationships for tasks. This should be done by detecting what tasks are |
172 // Born during the running of a parent task. The resulting data can be used by | 169 // Born during the running of a parent task. The resulting data can be used by |
173 // a smarter profiler to aggregate the cost of a series of child tasks into | 170 // a smarter profiler to aggregate the cost of a series of child tasks into |
174 // the ancestor task. It can also be used to illuminate what child or parent is | 171 // the ancestor task. It can also be used to illuminate what child or parent is |
175 // related to each task. | 172 // related to each task. |
176 // | 173 // |
177 // TODO(jar): We need to store DataCollections, and provide facilities for | 174 // TODO(jar): We need to store DataCollections, and provide facilities for |
178 // taking the difference between two gathered DataCollections. For now, we're | 175 // taking the difference between two gathered DataCollections. For now, we're |
179 // just adding a hack that Reset()s to zero all counts and stats. This is also | 176 // just adding a hack that Reset()s to zero all counts and stats. This is also |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // assumes ownership of the returned instance. | 271 // assumes ownership of the returned instance. |
275 base::DictionaryValue* ToValue() const; | 272 base::DictionaryValue* ToValue() const; |
276 | 273 |
277 // Reset the max values to zero. | 274 // Reset the max values to zero. |
278 void ResetMax(); | 275 void ResetMax(); |
279 | 276 |
280 // Reset all tallies to zero. This is used as a hack on realtime data. | 277 // Reset all tallies to zero. This is used as a hack on realtime data. |
281 void Clear(); | 278 void Clear(); |
282 | 279 |
283 private: | 280 private: |
284 // Number of runs seen. | 281 // Members are ordered from most regularly read and updated, to least |
| 282 // frequently used. This might help a bit with cache lines. |
| 283 // Number of runs seen (divisor for calculating averages). |
285 int count_; | 284 int count_; |
286 // Data about run time durations. | 285 // Basic tallies, used to compute averages. |
287 DurationInt run_duration_sum_; | 286 DurationInt run_duration_sum_; |
| 287 DurationInt queue_duration_sum_; |
| 288 // Max values, used by local visualization routines. These are often read, |
| 289 // but rarely updated. |
288 DurationInt run_duration_max_; | 290 DurationInt run_duration_max_; |
| 291 DurationInt queue_duration_max_; |
| 292 // Samples, used by by crowd sourcing gatherers. These are almost never read, |
| 293 // and rarely updated. |
289 DurationInt run_duration_sample_; | 294 DurationInt run_duration_sample_; |
290 // Data about queueing times durations. | |
291 DurationInt queue_duration_sum_; | |
292 DurationInt queue_duration_max_; | |
293 DurationInt queue_duration_sample_; | 295 DurationInt queue_duration_sample_; |
294 }; | 296 }; |
295 | 297 |
296 //------------------------------------------------------------------------------ | 298 //------------------------------------------------------------------------------ |
297 // A temporary collection of data that can be sorted and summarized. It is | 299 // A temporary collection of data that can be sorted and summarized. It is |
298 // gathered (carefully) from many threads. Instances are held in arrays and | 300 // gathered (carefully) from many threads. Instances are held in arrays and |
299 // processed, filtered, and rendered. | 301 // processed, filtered, and rendered. |
300 // The source of this data was collected on many threads, and is asynchronously | 302 // The source of this data was collected on many threads, and is asynchronously |
301 // changing. The data in this instance is not asynchronously changing. | 303 // changing. The data in this instance is not asynchronously changing. |
302 | 304 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 } | 673 } |
672 | 674 |
673 private: | 675 private: |
674 | 676 |
675 DISALLOW_COPY_AND_ASSIGN(AutoTracking); | 677 DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
676 }; | 678 }; |
677 | 679 |
678 } // namespace tracked_objects | 680 } // namespace tracked_objects |
679 | 681 |
680 #endif // BASE_TRACKED_OBJECTS_H_ | 682 #endif // BASE_TRACKED_OBJECTS_H_ |
OLD | NEW |