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

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

Issue 2967023002: android: Add thread time to early TraceEvent, make timings more precise. (Closed)
Patch Set: . Created 3 years, 5 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 (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_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
7 7
8 // This header file defines implementation details of how the trace macros in 8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not 9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_event_common.h instead of here. 10 // implementation-specific should go in trace_event_common.h instead of here.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ->AddTraceEventWithThreadIdAndTimestamp 176 ->AddTraceEventWithThreadIdAndTimestamp
177 177
178 // Set the duration field of a COMPLETE trace event. 178 // Set the duration field of a COMPLETE trace event.
179 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 179 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
180 // const unsigned char* category_group_enabled, 180 // const unsigned char* category_group_enabled,
181 // const char* name, 181 // const char* name,
182 // base::trace_event::TraceEventHandle id) 182 // base::trace_event::TraceEventHandle id)
183 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 183 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
184 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration 184 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration
185 185
186 // Set the duration field of a COMPLETE trace event.
187 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION_EXPLICIT(
188 // const unsigned char* category_group_enabled,
189 // const char* name,
190 // base::trace_event::TraceEventHandle id,
191 // const TimeTicks& now,
192 // const ThreadTicks* thread_now)
193 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION_EXPLICIT \
194 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDurationExplicit
195
186 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method 196 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method
187 // on the convertable value will be called at flush time. 197 // on the convertable value will be called at flush time.
188 // TRACE_EVENT_API_ADD_METADATA_EVENT( 198 // TRACE_EVENT_API_ADD_METADATA_EVENT(
189 // const unsigned char* category_group_enabled, 199 // const unsigned char* category_group_enabled,
190 // const char* event_name, 200 // const char* event_name,
191 // const char* arg_name, 201 // const char* arg_name,
192 // std::unique_ptr<ConvertableToTraceFormat> arg_value) 202 // std::unique_ptr<ConvertableToTraceFormat> arg_value)
193 #define TRACE_EVENT_API_ADD_METADATA_EVENT \ 203 #define TRACE_EVENT_API_ADD_METADATA_EVENT \
194 trace_event_internal::AddMetadataEvent 204 trace_event_internal::AddMetadataEvent
195 205
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 flags | trace_event_trace_id.id_flags(); \ 342 flags | trace_event_trace_id.id_flags(); \
333 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 343 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
334 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 344 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
335 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 345 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \
336 thread_id, timestamp, \ 346 thread_id, timestamp, \
337 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 347 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
338 trace_event_internal::kNoId, ##__VA_ARGS__); \ 348 trace_event_internal::kNoId, ##__VA_ARGS__); \
339 } \ 349 } \
340 } while (0) 350 } while (0)
341 351
352 // Implementation detail: internal macro to create static category and add
353 // event if the category is enabled.
354 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMPS( \
355 category_group, name, id, thread_id, begin_timestamp, end_timestamp, \
356 thread_end_timestamp, flags, ...) \
357 do { \
358 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
359 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED()) { \
360 trace_event_internal::TraceID trace_event_trace_id((id)); \
361 unsigned int trace_event_flags = \
362 flags | trace_event_trace_id.id_flags(); \
363 const unsigned char* uid_category_group_enabled = \
364 INTERNAL_TRACE_EVENT_UID(category_group_enabled); \
365 auto handle = \
366 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
367 TRACE_EVENT_PHASE_COMPLETE, uid_category_group_enabled, name, \
368 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \
369 thread_id, begin_timestamp, \
370 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
371 trace_event_internal::kNoId, ##__VA_ARGS__); \
372 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION_EXPLICIT( \
Primiano Tucci (use gerrit) 2017/07/10 13:09:15 (mostly note to future-myself and git archaeologis
373 uid_category_group_enabled, name, handle, end_timestamp, \
374 thread_end_timestamp); \
375 } \
376 } while (0)
377
342 // The linked ID will not be mangled. 378 // The linked ID will not be mangled.
343 #define INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id1, id2) \ 379 #define INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id1, id2) \
344 do { \ 380 do { \
345 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 381 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
346 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED()) { \ 382 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED()) { \
347 trace_event_internal::TraceID source_id((id1)); \ 383 trace_event_internal::TraceID source_id((id1)); \
348 unsigned int source_flags = source_id.id_flags(); \ 384 unsigned int source_flags = source_id.id_flags(); \
349 trace_event_internal::TraceID target_id((id2)); \ 385 trace_event_internal::TraceID target_id((id2)); \
350 trace_event_internal::AddTraceEvent( \ 386 trace_event_internal::AddTraceEvent( \
351 TRACE_EVENT_PHASE_LINK_IDS, \ 387 TRACE_EVENT_PHASE_LINK_IDS, \
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 const char* name_; 1145 const char* name_;
1110 IDType id_; 1146 IDType id_;
1111 1147
1112 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1148 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1113 }; 1149 };
1114 1150
1115 } // namespace trace_event 1151 } // namespace trace_event
1116 } // namespace base 1152 } // namespace base
1117 1153
1118 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1154 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698