Index: src/base/platform/time.h |
diff --git a/src/base/platform/time.h b/src/base/platform/time.h |
index e17fc1d716dd85e54440f9eeced6ff7f65b3bf1b..be62014f91db7e0535d47cc7aa25737d9c1801f9 100644 |
--- a/src/base/platform/time.h |
+++ b/src/base/platform/time.h |
@@ -12,6 +12,9 @@ |
#include "src/base/bits.h" |
#include "src/base/macros.h" |
#include "src/base/safe_math.h" |
+#if V8_OS_WIN |
+#include "src/base/win32-headers.h" |
+#endif |
// Forward declarations. |
extern "C" { |
@@ -380,17 +383,42 @@ class ThreadTicks final : public time_internal::TimeBase<ThreadTicks> { |
// Returns true if ThreadTicks::Now() is supported on this system. |
static bool IsSupported(); |
+ // Waits until the initialization is completed. Needs to be guarded with a |
+ // call to IsSupported(). |
+ static void WaitUntilInitialized() { |
+#if V8_OS_WIN |
+ WaitUntilInitializedWin(); |
+#endif |
+ } |
+ |
// 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. |
+ // object until the initialization is completed. If a clock reading is |
+ // absolutely needed, call WaitUntilInitialized() before this method. |
static ThreadTicks Now(); |
+#if V8_OS_WIN |
+ // Similar to Now() above except this returns thread-specific CPU time for an |
+ // arbitrary thread. All comments for Now() method above apply apply to this |
+ // method as well. |
+ static ThreadTicks GetForThread(const HANDLE& thread_handle); |
+#endif |
+ |
private: |
- // This is for internal use and testing. Ticks are in microseconds. |
+ // Please use Now() or GetForThread() to create a new object. This is for |
+ // internal use and testing. Ticks are in microseconds. |
explicit ThreadTicks(int64_t ticks) : TimeBase(ticks) {} |
+ |
+#if V8_OS_WIN |
+ // Returns the frequency of the TSC in ticks per second, or 0 if it hasn't |
+ // been measured yet. Needs to be guarded with a call to IsSupported(). |
+ static double TSCTicksPerSecond(); |
+ static bool IsSupportedWin(); |
+ static void WaitUntilInitializedWin(); |
+#endif |
}; |
} // namespace base |