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

Side by Side Diff: base/trace_event/trace_event_synthetic_delay.h

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // The synthetic delay framework makes it possible to dynamically inject 5 // The synthetic delay framework makes it possible to dynamically inject
6 // arbitrary delays into into different parts of the codebase. This can be used, 6 // arbitrary delays into into different parts of the codebase. This can be used,
7 // for instance, for testing various task scheduling algorithms. 7 // for instance, for testing various task scheduling algorithms.
8 // 8 //
9 // The delays are specified in terms of a target duration for a given block of 9 // The delays are specified in terms of a target duration for a given block of
10 // code. If the code executes faster than the duration, the thread is made to 10 // code. If the code executes faster than the duration, the thread is made to
(...skipping 11 matching lines...) Expand all
22 // TRACE_EVENT_SYNTHETIC_DELAY_END("cc.Scheduler.BeginMainFrame"); 22 // TRACE_EVENT_SYNTHETIC_DELAY_END("cc.Scheduler.BeginMainFrame");
23 // 23 //
24 // Here BEGIN establishes the start time for the delay and END executes the 24 // Here BEGIN establishes the start time for the delay and END executes the
25 // delay based on the remaining time. If BEGIN is called multiple times in a 25 // delay based on the remaining time. If BEGIN is called multiple times in a
26 // row, END should be called a corresponding number of times. Only the last 26 // row, END should be called a corresponding number of times. Only the last
27 // call to END will have an effect. 27 // call to END will have an effect.
28 // 28 //
29 // Note that a single delay may begin on one thread and end on another. This 29 // Note that a single delay may begin on one thread and end on another. This
30 // implies that a single delay cannot not be applied in several threads at once. 30 // implies that a single delay cannot not be applied in several threads at once.
31 31
32 #ifndef BASE_DEBUG_TRACE_EVENT_SYNTHETIC_DELAY_H_ 32 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_
33 #define BASE_DEBUG_TRACE_EVENT_SYNTHETIC_DELAY_H_ 33 #define BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_
34 34
35 #include "base/atomicops.h" 35 #include "base/atomicops.h"
36 #include "base/debug/trace_event.h"
37 #include "base/synchronization/lock.h" 36 #include "base/synchronization/lock.h"
38 #include "base/time/time.h" 37 #include "base/time/time.h"
38 #include "base/trace_event/trace_event.h"
39 39
40 // Apply a named delay in the current scope. 40 // Apply a named delay in the current scope.
41 #define TRACE_EVENT_SYNTHETIC_DELAY(name) \ 41 #define TRACE_EVENT_SYNTHETIC_DELAY(name) \
42 static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(impl_ptr) = 0; \ 42 static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(impl_ptr) = 0; \
43 trace_event_internal::ScopedSyntheticDelay INTERNAL_TRACE_EVENT_UID(delay)( \ 43 trace_event_internal::ScopedSyntheticDelay INTERNAL_TRACE_EVENT_UID(delay)( \
44 name, &INTERNAL_TRACE_EVENT_UID(impl_ptr)); 44 name, &INTERNAL_TRACE_EVENT_UID(impl_ptr));
45 45
46 // Begin a named delay, establishing its timing start point. May be called 46 // Begin a named delay, establishing its timing start point. May be called
47 // multiple times as long as the calls to TRACE_EVENT_SYNTHETIC_DELAY_END are 47 // multiple times as long as the calls to TRACE_EVENT_SYNTHETIC_DELAY_END are
48 // balanced. Only the first call records the timing start point. 48 // balanced. Only the first call records the timing start point.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay); 157 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay);
158 }; 158 };
159 159
160 // Helper for registering delays. Do not use directly. 160 // Helper for registering delays. Do not use directly.
161 TRACE_EVENT_API_CLASS_EXPORT base::debug::TraceEventSyntheticDelay* 161 TRACE_EVENT_API_CLASS_EXPORT base::debug::TraceEventSyntheticDelay*
162 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr); 162 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr);
163 163
164 } // namespace trace_event_internal 164 } // namespace trace_event_internal
165 165
166 #endif /* BASE_DEBUG_TRACE_EVENT_SYNTHETIC_DELAY_H_ */ 166 #endif /* BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ */
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory_unittest.cc ('k') | base/trace_event/trace_event_synthetic_delay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698