Page MenuHomePhabricator

Add a convenience function for computing elapsed microtime deltas

Authored by epriestley on Nov 8 2018, 2:13 PM.



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

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

$start = microtime(true);


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

Diff Detail

rPHU libphutil
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.Nov 8 2018, 2:13 PM
epriestley requested review of this revision.Nov 8 2018, 2:14 PM
amckinley accepted this revision.Nov 8 2018, 7:53 PM
This revision is now accepted and ready to land.Nov 8 2018, 7:53 PM
This revision was automatically updated to reflect the committed changes.