OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 10 #include <set> |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Default initializer. | 254 // Default initializer. |
255 DeathData(); | 255 DeathData(); |
256 | 256 |
257 // When deaths have not yet taken place, and we gather data from all the | 257 // When deaths have not yet taken place, and we gather data from all the |
258 // threads, we create DeathData stats that tally the number of births without | 258 // threads, we create DeathData stats that tally the number of births without |
259 // a corresponding death. | 259 // a corresponding death. |
260 explicit DeathData(int count); | 260 explicit DeathData(int count); |
261 | 261 |
262 // Update stats for a task destruction (death) that had a Run() time of | 262 // Update stats for a task destruction (death) that had a Run() time of |
263 // |duration|, and has had a queueing delay of |queue_duration|. | 263 // |duration|, and has had a queueing delay of |queue_duration|. |
264 void RecordDeath(const DurationInt queue_duration, | 264 void RecordDeath(const int32 queue_duration, |
265 const DurationInt run_duration, | 265 const int32 run_duration, |
266 int random_number); | 266 int random_number); |
267 | 267 |
268 // Metrics accessors, used only in tests. | 268 // Metrics accessors, used only in tests. |
269 int count() const; | 269 int count() const; |
270 DurationInt run_duration_sum() const; | 270 int32 run_duration_sum() const; |
271 DurationInt run_duration_max() const; | 271 int32 run_duration_max() const; |
272 DurationInt run_duration_sample() const; | 272 int32 run_duration_sample() const; |
273 DurationInt queue_duration_sum() const; | 273 int32 queue_duration_sum() const; |
274 DurationInt queue_duration_max() const; | 274 int32 queue_duration_max() const; |
275 DurationInt queue_duration_sample() const; | 275 int32 queue_duration_sample() const; |
276 | 276 |
277 // Construct a DictionaryValue instance containing all our stats. The caller | 277 // Construct a DictionaryValue instance containing all our stats. The caller |
278 // assumes ownership of the returned instance. | 278 // assumes ownership of the returned instance. |
279 base::DictionaryValue* ToValue() const; | 279 base::DictionaryValue* ToValue() const; |
280 | 280 |
281 // Reset the max values to zero. | 281 // Reset the max values to zero. |
282 void ResetMax(); | 282 void ResetMax(); |
283 | 283 |
284 // Reset all tallies to zero. This is used as a hack on realtime data. | 284 // Reset all tallies to zero. This is used as a hack on realtime data. |
285 void Clear(); | 285 void Clear(); |
286 | 286 |
287 private: | 287 private: |
288 // Members are ordered from most regularly read and updated, to least | 288 // Members are ordered from most regularly read and updated, to least |
289 // frequently used. This might help a bit with cache lines. | 289 // frequently used. This might help a bit with cache lines. |
290 // Number of runs seen (divisor for calculating averages). | 290 // Number of runs seen (divisor for calculating averages). |
291 int count_; | 291 int count_; |
292 // Basic tallies, used to compute averages. | 292 // Basic tallies, used to compute averages. |
293 DurationInt run_duration_sum_; | 293 int32 run_duration_sum_; |
294 DurationInt queue_duration_sum_; | 294 int32 queue_duration_sum_; |
295 // Max values, used by local visualization routines. These are often read, | 295 // Max values, used by local visualization routines. These are often read, |
296 // but rarely updated. | 296 // but rarely updated. |
297 DurationInt run_duration_max_; | 297 int32 run_duration_max_; |
298 DurationInt queue_duration_max_; | 298 int32 queue_duration_max_; |
299 // Samples, used by by crowd sourcing gatherers. These are almost never read, | 299 // Samples, used by by crowd sourcing gatherers. These are almost never read, |
300 // and rarely updated. | 300 // and rarely updated. |
301 DurationInt run_duration_sample_; | 301 int32 run_duration_sample_; |
302 DurationInt queue_duration_sample_; | 302 int32 queue_duration_sample_; |
303 }; | 303 }; |
304 | 304 |
305 //------------------------------------------------------------------------------ | 305 //------------------------------------------------------------------------------ |
306 // A temporary collection of data that can be sorted and summarized. It is | 306 // A temporary collection of data that can be sorted and summarized. It is |
307 // gathered (carefully) from many threads. Instances are held in arrays and | 307 // gathered (carefully) from many threads. Instances are held in arrays and |
308 // processed, filtered, and rendered. | 308 // processed, filtered, and rendered. |
309 // The source of this data was collected on many threads, and is asynchronously | 309 // The source of this data was collected on many threads, and is asynchronously |
310 // changing. The data in this instance is not asynchronously changing. | 310 // changing. The data in this instance is not asynchronously changing. |
311 | 311 |
312 class BASE_EXPORT Snapshot { | 312 class BASE_EXPORT Snapshot { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 static ThreadData* first(); | 507 static ThreadData* first(); |
508 | 508 |
509 // Iterate through the null terminated list of ThreadData instances. | 509 // Iterate through the null terminated list of ThreadData instances. |
510 ThreadData* next() const; | 510 ThreadData* next() const; |
511 | 511 |
512 | 512 |
513 // In this thread's data, record a new birth. | 513 // In this thread's data, record a new birth. |
514 Births* TallyABirth(const Location& location); | 514 Births* TallyABirth(const Location& location); |
515 | 515 |
516 // Find a place to record a death on this thread. | 516 // Find a place to record a death on this thread. |
517 void TallyADeath(const Births& birth, | 517 void TallyADeath(const Births& birth, int32 queue_duration, int32 duration); |
518 DurationInt queue_duration, | |
519 DurationInt duration); | |
520 | 518 |
521 // Using our lock, make a copy of the specified maps. This call may be made | 519 // Using our lock, make a copy of the specified maps. This call may be made |
522 // on non-local threads, which necessitate the use of the lock to prevent | 520 // on non-local threads, which necessitate the use of the lock to prevent |
523 // the map(s) from being reallocaed while they are copied. If |reset_max| is | 521 // the map(s) from being reallocaed while they are copied. If |reset_max| is |
524 // true, then, just after we copy the DeathMap, we will set the max values to | 522 // true, then, just after we copy the DeathMap, we will set the max values to |
525 // zero in the active DeathMap (not the snapshot). | 523 // zero in the active DeathMap (not the snapshot). |
526 void SnapshotMaps(bool reset_max, | 524 void SnapshotMaps(bool reset_max, |
527 BirthMap* birth_map, | 525 BirthMap* birth_map, |
528 DeathMap* death_map, | 526 DeathMap* death_map, |
529 ParentChildSet* parent_child_set); | 527 ParentChildSet* parent_child_set); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 708 |
711 // The complete list of parent-child relationships among tasks. | 709 // The complete list of parent-child relationships among tasks. |
712 ThreadData::ParentChildSet parent_child_set_; | 710 ThreadData::ParentChildSet parent_child_set_; |
713 | 711 |
714 DISALLOW_COPY_AND_ASSIGN(DataCollector); | 712 DISALLOW_COPY_AND_ASSIGN(DataCollector); |
715 }; | 713 }; |
716 | 714 |
717 } // namespace tracked_objects | 715 } // namespace tracked_objects |
718 | 716 |
719 #endif // BASE_TRACKED_OBJECTS_H_ | 717 #endif // BASE_TRACKED_OBJECTS_H_ |
OLD | NEW |