OLD | NEW |
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 15 matching lines...) Expand all Loading... |
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_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ | 32 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ |
33 #define BASE_TRACE_EVENT_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/macros.h" |
36 #include "base/synchronization/lock.h" | 37 #include "base/synchronization/lock.h" |
37 #include "base/time/time.h" | 38 #include "base/time/time.h" |
38 #include "base/trace_event/trace_event.h" | 39 #include "base/trace_event/trace_event.h" |
39 | 40 |
40 // Apply a named delay in the current scope. | 41 // Apply a named delay in the current scope. |
41 #define TRACE_EVENT_SYNTHETIC_DELAY(name) \ | 42 #define TRACE_EVENT_SYNTHETIC_DELAY(name) \ |
42 static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(impl_ptr) = 0; \ | 43 static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(impl_ptr) = 0; \ |
43 trace_event_internal::ScopedSyntheticDelay INTERNAL_TRACE_EVENT_UID(delay)( \ | 44 trace_event_internal::ScopedSyntheticDelay INTERNAL_TRACE_EVENT_UID(delay)( \ |
44 name, &INTERNAL_TRACE_EVENT_UID(impl_ptr)); | 45 name, &INTERNAL_TRACE_EVENT_UID(impl_ptr)); |
45 | 46 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay); | 158 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay); |
158 }; | 159 }; |
159 | 160 |
160 // Helper for registering delays. Do not use directly. | 161 // Helper for registering delays. Do not use directly. |
161 TRACE_EVENT_API_CLASS_EXPORT base::trace_event::TraceEventSyntheticDelay* | 162 TRACE_EVENT_API_CLASS_EXPORT base::trace_event::TraceEventSyntheticDelay* |
162 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr); | 163 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr); |
163 | 164 |
164 } // namespace trace_event_internal | 165 } // namespace trace_event_internal |
165 | 166 |
166 #endif // BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ | 167 #endif // BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ |
OLD | NEW |