diff options
author | wangxianzhu <wangxianzhu@chromium.org> | 2015-02-23 11:13:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-23 19:14:26 +0000 |
commit | 02769c33ee568c5329ce85702428635e2ef442ee (patch) | |
tree | 798e2d9d9fc1736a0be2f61314454ff8ee862b6e /base/trace_event | |
parent | 88db1a01502634619859cc428151bc571d6eebac (diff) | |
download | chromium_src-02769c33ee568c5329ce85702428635e2ef442ee.zip chromium_src-02769c33ee568c5329ce85702428635e2ef442ee.tar.gz chromium_src-02769c33ee568c5329ce85702428635e2ef442ee.tar.bz2 |
Avoid twice clock reading
Add TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP which is set when an explicit
timestamp is specified for the trace event. Only re-read clock if the
flag is set.
BUG=457441
Review URL: https://codereview.chromium.org/928563003
Cr-Commit-Position: refs/heads/master@{#317618}
Diffstat (limited to 'base/trace_event')
-rw-r--r-- | base/trace_event/trace_event.h | 7 | ||||
-rw-r--r-- | base/trace_event/trace_event_impl.cc | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h index 07a2afa..e12d8f4 100644 --- a/base/trace_event/trace_event.h +++ b/base/trace_event/trace_event.h @@ -1008,7 +1008,8 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ name, trace_event_trace_id.data(), \ thread_id, base::TimeTicks::FromInternalValue(timestamp), \ - trace_event_flags, ##__VA_ARGS__); \ + trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ + ##__VA_ARGS__); \ } \ } while (0) @@ -1045,9 +1046,11 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned char>(1 << 3)) +#define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned char>(1 << 4)) +#define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned char>(1 << 5)) #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned char>( \ - TRACE_EVENT_FLAG_SCOPE_OFFSET | (TRACE_EVENT_FLAG_SCOPE_OFFSET << 1))) + TRACE_EVENT_FLAG_SCOPE_OFFSET | TRACE_EVENT_FLAG_SCOPE_EXTRA)) // Type values for identifying types in the TraceValue union. #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc index 9ca0ddc..445cb6d 100644 --- a/base/trace_event/trace_event_impl.cc +++ b/base/trace_event/trace_event_impl.cc @@ -1914,7 +1914,8 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( id ^= process_id_hash_; TimeTicks offset_event_timestamp = OffsetTimestamp(timestamp); - TimeTicks now = OffsetNow(); + TimeTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ? + OffsetNow() : offset_event_timestamp; TimeTicks thread_now = ThreadNow(); ThreadLocalEventBuffer* thread_local_event_buffer = NULL; @@ -2035,9 +2036,6 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( } } - // Use |now| instead of |offset_event_timestamp| to compute overhead, because - // event timestamp may be not the real time that we started to add the event - // (e.g. event with zero timestamp or that was generated some time ago). if (thread_local_event_buffer) thread_local_event_buffer->ReportOverhead(now, thread_now); |