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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <stack> | 10 #include <stack> |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 ~DeathData(); | 323 ~DeathData(); |
324 | 324 |
325 // Update stats for a task destruction (death) that had a Run() time of | 325 // Update stats for a task destruction (death) that had a Run() time of |
326 // |duration|, and has had a queueing delay of |queue_duration|. | 326 // |duration|, and has had a queueing delay of |queue_duration|. |
327 void RecordDeath(const int32 queue_duration, | 327 void RecordDeath(const int32 queue_duration, |
328 const int32 run_duration, | 328 const int32 run_duration, |
329 const uint32 random_number); | 329 const uint32 random_number); |
330 | 330 |
331 // Metrics and past snapshots accessors, used only for serialization and in | 331 // Metrics and past snapshots accessors, used only for serialization and in |
332 // tests. | 332 // tests. |
333 int count() const; | 333 int count() const { return count_; } |
334 int32 run_duration_sum() const; | 334 int32 run_duration_sum() const { return run_duration_sum_; } |
335 int32 run_duration_max() const; | 335 int32 run_duration_max() const { return run_duration_max_; } |
336 int32 run_duration_sample() const; | 336 int32 run_duration_sample() const { return run_duration_sample_; } |
337 int32 queue_duration_sum() const; | 337 int32 queue_duration_sum() const { return queue_duration_sum_; } |
338 int32 queue_duration_max() const; | 338 int32 queue_duration_max() const { return queue_duration_max_; } |
339 int32 queue_duration_sample() const; | 339 int32 queue_duration_sample() const { return queue_duration_sample_; } |
340 const DeathDataPhaseSnapshot* last_phase_snapshot() const; | 340 const DeathDataPhaseSnapshot* last_phase_snapshot() const { |
| 341 return last_phase_snapshot_; |
| 342 } |
341 | 343 |
342 // Called when the current profiling phase, identified by |profiling_phase|, | 344 // Called when the current profiling phase, identified by |profiling_phase|, |
343 // ends. | 345 // ends. |
344 // Must be called only on the snapshot thread. | 346 // Must be called only on the snapshot thread. |
345 void OnProfilingPhaseCompleted(int profiling_phase); | 347 void OnProfilingPhaseCompleted(int profiling_phase); |
346 | 348 |
347 private: | 349 private: |
348 // Members are ordered from most regularly read and updated, to least | 350 // Members are ordered from most regularly read and updated, to least |
349 // frequently used. This might help a bit with cache lines. | 351 // frequently used. This might help a bit with cache lines. |
350 // Number of runs seen (divisor for calculating averages). | 352 // Number of runs seen (divisor for calculating averages). |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 const TaskStopwatch& stopwatch); | 492 const TaskStopwatch& stopwatch); |
491 | 493 |
492 // Record the end of execution in region, generally corresponding to a scope | 494 // Record the end of execution in region, generally corresponding to a scope |
493 // being exited. | 495 // being exited. |
494 static void TallyRunInAScopedRegionIfTracking(const Births* births, | 496 static void TallyRunInAScopedRegionIfTracking(const Births* births, |
495 const TaskStopwatch& stopwatch); | 497 const TaskStopwatch& stopwatch); |
496 | 498 |
497 const std::string& thread_name() const { return thread_name_; } | 499 const std::string& thread_name() const { return thread_name_; } |
498 | 500 |
499 // Initializes all statics if needed (this initialization call should be made | 501 // Initializes all statics if needed (this initialization call should be made |
500 // while we are single threaded). Returns false if unable to initialize. | 502 // while we are single threaded). |
501 static bool Initialize(); | 503 static void Initialize(); |
502 | 504 |
503 // Sets internal status_. | 505 // Sets internal status_. |
504 // If |status| is false, then status_ is set to DEACTIVATED. | 506 // If |status| is false, then status_ is set to DEACTIVATED. |
505 // If |status| is true, then status_ is set to PROFILING_ACTIVE. | 507 // If |status| is true, then status_ is set to PROFILING_ACTIVE. |
506 // If it fails to initialize the TLS slot, this function will return false. | 508 static void InitializeAndSetTrackingStatus(Status status); |
507 static bool InitializeAndSetTrackingStatus(Status status); | |
508 | 509 |
509 static Status status(); | 510 static Status status(); |
510 | 511 |
511 // Indicate if any sort of profiling is being done (i.e., we are more than | 512 // Indicate if any sort of profiling is being done (i.e., we are more than |
512 // DEACTIVATED). | 513 // DEACTIVATED). |
513 static bool TrackingStatus(); | 514 static bool TrackingStatus(); |
514 | 515 |
515 // Enables profiler timing. | 516 // Enables profiler timing. |
516 static void EnableProfilerTiming(); | 517 static void EnableProfilerTiming(); |
517 | 518 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 ProcessDataSnapshot(); | 803 ProcessDataSnapshot(); |
803 ~ProcessDataSnapshot(); | 804 ~ProcessDataSnapshot(); |
804 | 805 |
805 PhasedProcessDataSnapshotMap phased_snapshots; | 806 PhasedProcessDataSnapshotMap phased_snapshots; |
806 base::ProcessId process_id; | 807 base::ProcessId process_id; |
807 }; | 808 }; |
808 | 809 |
809 } // namespace tracked_objects | 810 } // namespace tracked_objects |
810 | 811 |
811 #endif // BASE_TRACKED_OBJECTS_H_ | 812 #endif // BASE_TRACKED_OBJECTS_H_ |
OLD | NEW |