Re: Fwd: Monotonic Time
| From: | Fleshgrinder | Date: | Mon, 06 Feb 2017 16:45:01 +0000 |
| Subject: | Re: Fwd: Monotonic Time | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98217@lists.php.net to get a copy of this message | ||
On 2/6/2017 1:33 PM, Anatol Belski wrote:
> With the names and API, probably some more clarity should be. AFM,
> the low level units should be exposed, rather than a concrete time.
> Also, the name hrtime() is probably not much speaking. Maybe these
> three?
>
> sys_get_monotonic_ticks()
> sys_get_monotonic_freq()
> sys_get_monotonic_nanotime() or even -
> sys_get_monotonic_time(int $unit = NANOSECOND)
>
> Regarding to "sys_get_*" scheme with these. But in general, probably
> nanoseconds were enough for the general case and fast, the pure ticks
> were for the advanced usage.
>
> In general, probably for the core it should be done a more robust
> way, some parts on the original lib should get more error checks and
> improved. It would be probably more handy to discuss the further on
> the PR page.
>
> Regards
>
> Anatol
>
Hey guys! :)
Please do not introduce more functions that require flags, it makes code
hard to read. It's much better to have dedicated functions that provide
exactly what is requested. A good bad example is
microtime() vs
microtime(true). :(
sys_get_monotonic_nanotime() is rather long but at least descriptive.
Obviously providing a class could help with naming a lot and future
extension would be easy, e.g. MonotonicTime::getNanoseconds().
--
Richard "Fleshgrinder" Fussenegger