diff options
author | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-17 01:39:37 +0000 |
---|---|---|
committer | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-17 01:39:37 +0000 |
commit | d22a3099e47aaf3f3c424c5c6719e4b8d492e27c (patch) | |
tree | 9a3b2bebb129c5623b45ead1a80433ebe8acf2d6 /base/debug | |
parent | fde7cd9129dca794d697937c6bf49505374cf4fd (diff) | |
download | chromium_src-d22a3099e47aaf3f3c424c5c6719e4b8d492e27c.zip chromium_src-d22a3099e47aaf3f3c424c5c6719e4b8d492e27c.tar.gz chromium_src-d22a3099e47aaf3f3c424c5c6719e4b8d492e27c.tar.bz2 |
Add thread-specific CPU-time to trace events.
R=nduca@chromium.org
BUG=264306
Review URL: https://chromiumcodereview.appspot.com/22882005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r-- | base/debug/trace_event_impl.cc | 18 | ||||
-rw-r--r-- | base/debug/trace_event_impl.h | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc index b85aeca..2f63f91 100644 --- a/base/debug/trace_event_impl.cc +++ b/base/debug/trace_event_impl.cc @@ -309,6 +309,7 @@ TraceEvent::TraceEvent() TraceEvent::TraceEvent( int thread_id, TimeTicks timestamp, + TimeTicks thread_timestamp, char phase, const unsigned char* category_group_enabled, const char* name, @@ -320,12 +321,14 @@ TraceEvent::TraceEvent( scoped_ptr<ConvertableToTraceFormat> convertable_values[], unsigned char flags) : timestamp_(timestamp), + thread_timestamp_(thread_timestamp), id_(id), category_group_enabled_(category_group_enabled), name_(name), thread_id_(thread_id), phase_(phase), flags_(flags) { + // Clamp num_args since it may have been set by a third_party library. num_args = (num_args > kTraceMaxNumArgs) ? kTraceMaxNumArgs : num_args; int i = 0; @@ -391,6 +394,7 @@ TraceEvent::TraceEvent( TraceEvent::TraceEvent(const TraceEvent& other) : timestamp_(other.timestamp_), + thread_timestamp_(other.thread_timestamp_), id_(other.id_), category_group_enabled_(other.category_group_enabled_), name_(other.name_), @@ -418,6 +422,7 @@ TraceEvent& TraceEvent::operator=(const TraceEvent& other) { return *this; timestamp_ = other.timestamp_; + thread_timestamp_ = other.thread_timestamp_; id_ = other.id_; category_group_enabled_ = other.category_group_enabled_; name_ = other.name_; @@ -519,6 +524,12 @@ void TraceEvent::AppendAsJSON(std::string* out) const { } *out += "}"; + // Output tts if thread_timestamp is valid. + if (!thread_timestamp_.is_null()) { + int64 thread_time_int64 = thread_timestamp_.ToInternalValue(); + StringAppendF(out, ",\"tts\":%" PRId64, thread_time_int64); + } + // If id_ is set, print it out as a hex string so we don't loose any // bits (it might be a 64-bit pointer). if (flags_ & TRACE_EVENT_FLAG_HAS_ID) @@ -1200,6 +1211,9 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( return; TimeTicks now = timestamp - time_offset_; + base::TimeTicks thread_now; + if (base::TimeTicks::IsThreadNowSupported()) + thread_now = base::TimeTicks::ThreadNow(); EventCallback event_callback_copy; NotificationHelper notifier(this); @@ -1240,7 +1254,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( } TraceEvent trace_event(thread_id, - now, phase, category_group_enabled, name, id, + now, thread_now, phase, category_group_enabled, name, id, num_args, arg_names, arg_types, arg_values, convertable_values, flags); @@ -1370,7 +1384,7 @@ void AddMetadataEventToBuffer( trace_event_internal::SetTraceValue(value, &arg_type, &arg_value); logged_events->AddEvent(TraceEvent( thread_id, - TimeTicks(), TRACE_EVENT_PHASE_METADATA, + TimeTicks(), TimeTicks(), TRACE_EVENT_PHASE_METADATA, &g_category_group_enabled[g_category_metadata], metadata_name, trace_event_internal::kNoEventId, num_args, &arg_name, &arg_type, &arg_value, NULL, diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h index 1e9d9cd..e1bf148 100644 --- a/base/debug/trace_event_impl.h +++ b/base/debug/trace_event_impl.h @@ -81,6 +81,7 @@ class BASE_EXPORT TraceEvent { TraceEvent(); TraceEvent(int thread_id, TimeTicks timestamp, + TimeTicks thread_timestamp, char phase, const unsigned char* category_group_enabled, const char* name, @@ -108,6 +109,7 @@ class BASE_EXPORT TraceEvent { std::string* out); TimeTicks timestamp() const { return timestamp_; } + TimeTicks thread_timestamp() const { return thread_timestamp_; } // Exposed for unittesting: @@ -124,6 +126,7 @@ class BASE_EXPORT TraceEvent { private: // Note: these are ordered by size (largest first) for optimal packing. TimeTicks timestamp_; + TimeTicks thread_timestamp_; // id_ can be used to store phase-specific data. unsigned long long id_; TraceValue arg_values_[kTraceMaxNumArgs]; |