Commit d21bc224 authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

base: Reduce overhead of blame context tracking

When emitting trace events for blame contexts, first check whether
tracing is enabled. If tracing is disabled, we can avoid some of the
overhead associated with preparing to log a trace event (e.g., timestamp
lookup).

Bug: 678143
Change-Id: I6ca2ebf897d88eec7f8ad4b8557136af87524487
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847300
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703733}
parent 28045f64
......@@ -40,6 +40,8 @@ BlameContext::~BlameContext() {
void BlameContext::Enter() {
DCHECK(WasInitialized());
if (LIKELY(!*category_group_enabled_))
return;
TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_ENTER_CONTEXT,
category_group_enabled_, name_, scope_, id_,
nullptr, TRACE_EVENT_FLAG_HAS_ID);
......@@ -47,6 +49,8 @@ void BlameContext::Enter() {
void BlameContext::Leave() {
DCHECK(WasInitialized());
if (LIKELY(!*category_group_enabled_))
return;
TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_LEAVE_CONTEXT,
category_group_enabled_, name_, scope_, id_,
nullptr, TRACE_EVENT_FLAG_HAS_ID);
......@@ -55,7 +59,7 @@ void BlameContext::Leave() {
void BlameContext::TakeSnapshot() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(WasInitialized());
if (!*category_group_enabled_)
if (LIKELY(!*category_group_enabled_))
return;
std::unique_ptr<trace_event::TracedValue> snapshot(
new trace_event::TracedValue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment