Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15413211
D19796.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D19796.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -568,6 +568,7 @@
'phutil_json_encode' => 'utils/utils.php',
'phutil_load_library' => 'moduleutils/core.php',
'phutil_loggable_string' => 'utils/utils.php',
+ 'phutil_microseconds_since' => 'utils/utils.php',
'phutil_parse_bytes' => 'utils/viewutils.php',
'phutil_passthru' => 'future/exec/execx.php',
'phutil_person' => 'internationalization/pht.php',
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -1137,6 +1137,29 @@
}
+/**
+ * Compute the number of microseconds that have elapsed since an earlier
+ * timestamp (from `microtime(true)`).
+ *
+ * @param double Microsecond-precision timestamp, from `microtime(true)`.
+ * @return int Elapsed microseconds.
+ */
+function phutil_microseconds_since($timestamp) {
+ if (!is_float($timestamp)) {
+ throw new Exception(
+ pht(
+ 'Argument to "phutil_microseconds_since(...)" should be a value '.
+ 'returned from "microtime(true)".'));
+ }
+
+ $delta = (microtime(true) - $timestamp);
+ $delta = 1000000 * $delta;
+ $delta = (int)$delta;
+
+ return $delta;
+}
+
+
/**
* Decode a JSON dictionary.
*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 5:30 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7224375
Default Alt Text
D19796.diff (1 KB)
Attached To
Mode
D19796: Add a convenience function for computing elapsed microtime deltas
Attached
Detach File
Event Timeline
Log In to Comment