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

Unified Diff: cc/debug/worker_thread_cost_tracker.h

Issue 799863004: not for commit/review (thread cost tracker) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « cc/debug/frame_timing_cost_tracker.cc ('k') | cc/debug/worker_thread_cost_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/debug/worker_thread_cost_tracker.h
diff --git a/cc/debug/worker_thread_cost_tracker.h b/cc/debug/worker_thread_cost_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5686c95b4fc24f30fabb3bc0645c9c8f1d2b6da
--- /dev/null
+++ b/cc/debug/worker_thread_cost_tracker.h
@@ -0,0 +1,58 @@
+// 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.
+
+#ifndef CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
+#define CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
+
+namespace cc {
+
+class WorkerThreadCostTracker {
+ public:
+ class Probe {
+ public:
+ Probe(WorkerThreadCostTracker* tracker, int tracked_source_frame_number);
+ ~Probe();
+
+ void Start(int source_frame_number);
+ void Stop();
+
+ private:
+ WorkerThreadCostTracker* tracker_;
+ int tracked_source_frame_number_;
+ base::PlatformThreadId tracker_thread_id_;
+
+ bool started_;
+ base::TimeTicks start_;
+ base::TimeDelta cost_;
+
+ base::ThreadChecker thread_checker_;
+ };
+
+ WorkerThreadCostTracker();
+ ~WorkerThreadCostTracker();
+
+ void set_source_frame_to_track(int source_frame_number) {
+ source_frame_number_ = source_frame_number;
+ }
+ void reset_cost() { cost_ = base::TimeDelta(); }
+ base::TimeDelta get_cost() { return cost_; }
+
+ scoped_ptr<Probe> CreateProbe();
+
+ private:
+ friend class Probe;
+
+ void add_cost(const base::TimeDelta& cost) { cost_ += cost; }
+
+ int source_frame_number_;
+ base::TimeDelta cost_;
+};
+
+} // namespace cc
+
+#endif // CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
« no previous file with comments | « cc/debug/frame_timing_cost_tracker.cc ('k') | cc/debug/worker_thread_cost_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698