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

Unified Diff: src/base/platform/time.h

Issue 1959103004: Implement CPU time for OS X and POSIX. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | src/base/platform/time.cc » ('j') | src/base/platform/time.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/time.h
diff --git a/src/base/platform/time.h b/src/base/platform/time.h
index 834f74a9d9501f5431435312e36dd75bd786d3d7..ebe479347c57dcd6de4c8a97884fb62f1ed3768b 100644
--- a/src/base/platform/time.h
+++ b/src/base/platform/time.h
@@ -11,7 +11,6 @@
#include "src/base/bits.h"
#include "src/base/macros.h"
-#include "src/base/safe_math.h"
fmeawad 2016/05/09 21:50:32 Unrelated to this CL?
lpy 2016/05/09 22:13:41 Done.
// Forward declarations.
extern "C" {
@@ -368,6 +367,32 @@ inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) {
return ticks + delta;
}
+
+// ThreadTicks ----------------------------------------------------------------
+
+// Represents a clock, specific to a particular thread, than runs only while the
+// thread is running.
+class ThreadTicks final : public time_internal::TimeBase<ThreadTicks> {
+ public:
+ ThreadTicks() : TimeBase(0) {}
+
+ // Returns true if ThreadTicks::Now() is supported on this system.
+ static bool IsSupported();
+
+ // Returns thread-specific CPU-time on systems that support this feature.
+ // Needs to be guarded with a call to IsSupported(). Use this timer
+ // to (approximately) measure how much time the calling thread spent doing
+ // actual work vs. being de-scheduled. May return bogus results if the thread
+ // migrates to another CPU between two calls. Returns an empty ThreadTicks
+ // object until the initialization is completed.
+ static ThreadTicks Now();
+
+ private:
+ // Please use Now() or GetForThread() to create a new object. This is for
+ // internal use and testing. Ticks is in microseconds.
+ explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {}
+};
+
} // namespace base
} // namespace v8
« no previous file with comments | « no previous file | src/base/platform/time.cc » ('j') | src/base/platform/time.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698