Page MenuHomePhabricator

Add a convenience function for computing elapsed microtime deltas
ClosedPublic

Authored by epriestley on Nov 8 2018, 2:13 PM.
Tags
None
Referenced Files
F18984962: D19796.id47270.diff
Mon, Nov 17, 12:49 PM
F18960504: D19796.diff
Thu, Nov 13, 11:58 AM
F18807057: D19796.diff
Oct 18 2025, 10:47 PM
F18771800: D19796.id47274.diff
Oct 8 2025, 9:58 PM
F18763272: D19796.id47274.diff
Oct 6 2025, 11:33 PM
F18738626: D19796.diff
Oct 1 2025, 4:23 PM
F18737561: D19796.id47270.diff
Oct 1 2025, 11:24 AM
F18733830: D19796.id.diff
Sep 30 2025, 10:42 PM
Subscribers
None

Details

Summary

See D19780. We have a reasonable amount of 1000000 * ($t_end - $t_start) stuff in the codebase that we could simplify. In particular, it would be easy to have too many or too few 0s somewhere and escape notice.

I landed on this method signature instead of phutil_microseconds_between(x, y) since I think it would be hard to remember if parameter order is start, end (chronological) or end, start (like arithmetic subtraction). It should be a little simpler to use in most cases, too.

Test Plan
$ cat test.php
<?php

require_once 'scripts/init/init-script.php';

$start = microtime(true);

sleep(1);

echo phutil_microseconds_since($start);
echo "\n";
$ php -f test.php
1001921

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable