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

Unified Diff: include/v8-platform.h

Issue 97073004: Make Time functions go through the Platform layer. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 7 years, 1 month 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/default-platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8-platform.h
diff --git a/include/v8-platform.h b/include/v8-platform.h
index 75fddd59a873b75db0d05bd1e3fc733b1e1a9265..214c1e52eab0b011c2d5d9616dfcc752ab4f1849 100644
--- a/include/v8-platform.h
+++ b/include/v8-platform.h
@@ -77,6 +77,65 @@ class Platform {
*/
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
+ /**
+ * The current time, represented as microseconds (s/1,000,000) since
+ * 00:00:00 UTC, January 1, 1970.
+ *
+ * This value can go backwards, if the system adjusts its clock.
+ */
+ virtual int64_t CurrentTime();
+
+ /**
+ * The current time, represented as microseconds (s/1,000,000) since
+ * 00:00:00 UTC, January 1, 1970.
+ *
+ * This function always uses system time so that there are no discrepancies
+ * between the returned time and system time even on virtual environments,
+ * including our test bot.
+ *
+ * This value can go backwards, if the system adjusts its clock.
+ *
+ * This function is used for timing sensitive unittests.
+ */
+ virtual int64_t CurrentTimeFromSystemTime();
+
+ /**
+ * An abstract time intended for use in measuring time durations, represented
+ * as microseconds.
+ *
+ * This is guaranteed not to decrease even if the computer clock goes
+ * backwards, but it may "stand still", for example if the computer is
+ * suspended.
+ *
+ * The resolution of this clock can be as low as 15ms, and it varies
+ * depending on hardware/operating system.
+ *
+ * This method never returns 0.
+ */
+ virtual int64_t TimeTicksNow();
+
+ /**
+ * An abstract time intended for use in measuring time durations, represented
+ * as microseconds.
+ *
+ * This is guaranteed not to decrease even if the computer clock goes
+ * backwards, but it may "stand still", for example if the computer is
+ * suspended.
+ *
+ * The implementation is hardware dependent and its return values may or may
+ * not have sub-millisecond resolution. THIS CALL IS GENERALLY MUCH MORE
+ * EXPENSIVE THAN TimeTicksNow() AND SHOULD ONLY BE USED WHEN IT IS REALLY
+ * NEEDED.
+ *
+ * This method never returns 0.
+ */
+ virtual int64_t TimeTicksHighResNow();
+
+ /**
+ * True if the TimeTicksHighResNow() returns values with high resolution.
+ */
+ virtual bool TimeTicksHasHighRes();
+
protected:
virtual ~Platform() {}
};
« no previous file with comments | « no previous file | src/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698