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
F18284158: D19796.diff
Sat, Aug 23, 4:02 AM
F18112234: D19796.diff
Tue, Aug 12, 4:14 PM
F18100062: D19796.id47274.diff
Sat, Aug 9, 10:40 AM
F18095204: D19796.diff
Thu, Aug 7, 10:34 PM
F18091607: D19796.id47270.diff
Wed, Aug 6, 11:53 PM
F18018758: D19796.id.diff
Sat, Aug 2, 7:09 PM
F17953514: D19796.diff
Fri, Aug 1, 3:09 AM
F17847434: D19796.id47274.diff
Jul 27 2025, 6:08 AM
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