Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: base/tracked_objects.h

Issue 1640223002: profiler: cleanup unused alternate_timer code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: doc Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/profiler/alternate_timer.cc ('k') | base/tracked_objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <stack> 12 #include <stack>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/atomicops.h" 17 #include "base/atomicops.h"
18 #include "base/base_export.h" 18 #include "base/base_export.h"
19 #include "base/containers/hash_tables.h" 19 #include "base/containers/hash_tables.h"
20 #include "base/gtest_prod_util.h" 20 #include "base/gtest_prod_util.h"
21 #include "base/lazy_instance.h" 21 #include "base/lazy_instance.h"
22 #include "base/location.h" 22 #include "base/location.h"
23 #include "base/macros.h" 23 #include "base/macros.h"
24 #include "base/process/process_handle.h" 24 #include "base/process/process_handle.h"
25 #include "base/profiler/alternate_timer.h"
26 #include "base/profiler/tracked_time.h" 25 #include "base/profiler/tracked_time.h"
27 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
28 #include "base/threading/thread_checker.h" 27 #include "base/threading/thread_checker.h"
29 #include "base/threading/thread_local_storage.h" 28 #include "base/threading/thread_local_storage.h"
30 29
31 namespace base { 30 namespace base {
32 struct TrackingInfo; 31 struct TrackingInfo;
33 } 32 }
34 33
35 // TrackedObjects provides a database of stats about objects (generally Tasks) 34 // TrackedObjects provides a database of stats about objects (generally Tasks)
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 529
531 // Enables profiler timing. 530 // Enables profiler timing.
532 static void EnableProfilerTiming(); 531 static void EnableProfilerTiming();
533 532
534 // Provide a time function that does nothing (runs fast) when we don't have 533 // Provide a time function that does nothing (runs fast) when we don't have
535 // the profiler enabled. It will generally be optimized away when it is 534 // the profiler enabled. It will generally be optimized away when it is
536 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of 535 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of
537 // the code). 536 // the code).
538 static TrackedTime Now(); 537 static TrackedTime Now();
539 538
540 // Use the function |now| to provide current times, instead of calling the
541 // TrackedTime::Now() function. Since this alternate function is being used,
542 // the other time arguments (used for calculating queueing delay) will be
543 // ignored.
544 static void SetAlternateTimeSource(NowFunction* now);
545
546 // This function can be called at process termination to validate that thread 539 // This function can be called at process termination to validate that thread
547 // cleanup routines have been called for at least some number of named 540 // cleanup routines have been called for at least some number of named
548 // threads. 541 // threads.
549 static void EnsureCleanupWasCalled(int major_threads_shutdown_count); 542 static void EnsureCleanupWasCalled(int major_threads_shutdown_count);
550 543
551 private: 544 private:
552 friend class TaskStopwatch; 545 friend class TaskStopwatch;
553 // Allow only tests to call ShutdownSingleThreadedCleanup. We NEVER call it 546 // Allow only tests to call ShutdownSingleThreadedCleanup. We NEVER call it
554 // in production code. 547 // in production code.
555 // TODO(jar): Make this a friend in DEBUG only, so that the optimizer has a 548 // TODO(jar): Make this a friend in DEBUG only, so that the optimizer has a
556 // better change of optimizing (inlining? etc.) private methods (knowing that 549 // better change of optimizing (inlining? etc.) private methods (knowing that
557 // there will be no need for an external entry point). 550 // there will be no need for an external entry point).
558 friend class TrackedObjectsTest; 551 friend class TrackedObjectsTest;
559 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, MinimalStartupShutdown); 552 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, MinimalStartupShutdown);
560 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, TinyStartupShutdown); 553 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, TinyStartupShutdown);
561 554
555 // Type for an alternate timer function (testing only).
556 typedef unsigned int NowFunction();
557
562 typedef std::map<const BirthOnThread*, int> BirthCountMap; 558 typedef std::map<const BirthOnThread*, int> BirthCountMap;
563
564 typedef std::vector<std::pair<const Births*, DeathDataPhaseSnapshot>> 559 typedef std::vector<std::pair<const Births*, DeathDataPhaseSnapshot>>
565 DeathsSnapshot; 560 DeathsSnapshot;
566 561
567 // Worker thread construction creates a name since there is none. 562 // Worker thread construction creates a name since there is none.
568 explicit ThreadData(int thread_number); 563 explicit ThreadData(int thread_number);
569 564
570 // Message loop based construction should provide a name. 565 // Message loop based construction should provide a name.
571 explicit ThreadData(const std::string& suggested_name); 566 explicit ThreadData(const std::string& suggested_name);
572 567
573 ~ThreadData(); 568 ~ThreadData();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 // true, and the data structures (birth maps, death maps, ThreadData 623 // true, and the data structures (birth maps, death maps, ThreadData
629 // insntances, etc.) will be leaked and not deleted. If you have joined all 624 // insntances, etc.) will be leaked and not deleted. If you have joined all
630 // threads since the time that InitializeAndSetTrackingStatus() was called, 625 // threads since the time that InitializeAndSetTrackingStatus() was called,
631 // then you can pass in a |leak| value of false, and this function will 626 // then you can pass in a |leak| value of false, and this function will
632 // delete recursively all data structures, starting with the list of 627 // delete recursively all data structures, starting with the list of
633 // ThreadData instances. 628 // ThreadData instances.
634 static void ShutdownSingleThreadedCleanup(bool leak); 629 static void ShutdownSingleThreadedCleanup(bool leak);
635 630
636 // When non-null, this specifies an external function that supplies monotone 631 // When non-null, this specifies an external function that supplies monotone
637 // increasing time functcion. 632 // increasing time functcion.
638 static NowFunction* now_function_; 633 static NowFunction* now_function_for_testing_;
639
640 // If true, now_function_ returns values that can be used to calculate queue
641 // time.
642 static bool now_function_is_time_;
643 634
644 // We use thread local store to identify which ThreadData to interact with. 635 // We use thread local store to identify which ThreadData to interact with.
645 static base::ThreadLocalStorage::StaticSlot tls_index_; 636 static base::ThreadLocalStorage::StaticSlot tls_index_;
646 637
647 // List of ThreadData instances for use with worker threads. When a worker 638 // List of ThreadData instances for use with worker threads. When a worker
648 // thread is done (terminated), we push it onto this list. When a new worker 639 // thread is done (terminated), we push it onto this list. When a new worker
649 // thread is created, we first try to re-use a ThreadData instance from the 640 // thread is created, we first try to re-use a ThreadData instance from the
650 // list, and if none are available, construct a new one. 641 // list, and if none are available, construct a new one.
651 // This is only accessed while list_lock_ is held. 642 // This is only accessed while list_lock_ is held.
652 static ThreadData* first_retired_worker_; 643 static ThreadData* first_retired_worker_;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 ProcessDataSnapshot(); 809 ProcessDataSnapshot();
819 ~ProcessDataSnapshot(); 810 ~ProcessDataSnapshot();
820 811
821 PhasedProcessDataSnapshotMap phased_snapshots; 812 PhasedProcessDataSnapshotMap phased_snapshots;
822 base::ProcessId process_id; 813 base::ProcessId process_id;
823 }; 814 };
824 815
825 } // namespace tracked_objects 816 } // namespace tracked_objects
826 817
827 #endif // BASE_TRACKED_OBJECTS_H_ 818 #endif // BASE_TRACKED_OBJECTS_H_
OLDNEW
« no previous file with comments | « base/profiler/alternate_timer.cc ('k') | base/tracked_objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698