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

Unified Diff: Source/platform/scheduler/TracedTask.cpp

Issue 490913002: Adding flow traces for blink scheduler events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Merge with master and disable mangle Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scheduler/TracedTask.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/TracedTask.cpp
diff --git a/Source/platform/scheduler/TracedTask.cpp b/Source/platform/scheduler/TracedTask.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d4e1fa69f78c4535379dfbff2f49e00138acad4f
--- /dev/null
+++ b/Source/platform/scheduler/TracedTask.cpp
@@ -0,0 +1,41 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "platform/scheduler/TracedTask.h"
+
+namespace blink {
+
+volatile int TracedTask::s_nextFlowTraceID = 0;
+
+void TracedTask::run() const
+{
+ TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID));
+
+ TRACE_EVENT2("blink", m_traceName,
+ "src_file", m_location.fileName(),
+ "src_func", m_location.functionName());
+
+ m_task();
+}
+
+TracedTask::TracedTask(const Task& task, const TraceLocation& location, const char* traceName)
+ : m_task(task)
+ , m_location(location)
+ , m_traceName(traceName)
+{
+ bool tracingEnabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled);
+
+ if (tracingEnabled) {
+ // atomicIncrement is slow so we only do it if tracing is enabled
+ m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID));
+
+ TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID),
+ "src_file", m_location.fileName(),
+ "src_func", m_location.functionName());
+ }
+}
+
+} // namespace blink
« no previous file with comments | « Source/platform/scheduler/TracedTask.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698