Page MenuHomePhabricator

D19796.diff
No OneTemporary

D19796.diff

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

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)

Event Timeline