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
F19863578: D19796.id47274.diff
Sat, Mar 14, 11:45 AM
F19832746: D19796.id47274.diff
Tue, Mar 10, 11:55 PM
F19826117: D19796.diff
Sun, Mar 8, 5:26 PM
F19825224: D19796.diff
Sun, Mar 8, 9:23 AM
F19813470: D19796.diff
Wed, Mar 4, 9:33 AM
F19531480: D19796.id47270.diff
Jan 20 2026, 4:55 AM
F19525521: D19796.id.diff
Jan 18 2026, 9:36 AM
F19506754: D19796.id47274.diff
Jan 9 2026, 4:53 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