RE: [PHP-DEV] Fwd: Monotonic Time
| From: | Anatol Belski | Date: | Mon, 06 Feb 2017 12:33:09 +0000 |
| Subject: | RE: [PHP-DEV] Fwd: Monotonic Time | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98215@lists.php.net to get a copy of this message | ||
Hi Niklas,
> -----Original Message-----
> From: Niklas Keller [mailto:me@kelunik.com]
> Sent: Sunday, February 5, 2017 8:19 PM
> To: Anatol Belski <anatol.php@belski.net>
> Cc: Leigh <leight@gmail.com>; Michael Wallner <mike@php.net>; PHP Internals
> <internals@lists.php.net>; Bob Weinand <bwoebi@php.net>; Daniel Lowrey
> <rdlowrey@php.net>
> Subject: Re: [PHP-DEV] Fwd: Monotonic Time
>
> I have implemented a
hrtime() function which allows access to
> the system's
> monotonic time in nanoseconds.
>
Nice for the start.
>
> https://github.com/php/php-src/compare/master...kelunik:hrtime
>
>
> Feedback is very welcome.
>
> I'm not sure whether we should allow a parameter for the time unit or just let
> the user do the simple calculation.
>
I'd see this integration a bit different, as the goal is to put it into the core. Here some
quick points to maybe think about
- on the m4 side, symbols need to be checked
- the PHP internal and user stuff should be integrated tight into the timer.c file,
- a finer usage with the concrete platform should be taken care of, thus avoiding unnecessary
function calls and conversions back/forth as you can use
- there might be a situation, where the monotonic API could be used internally before modules are
initialized
- the symbols exported need to be renamed, probably prefix with php_monotonic_*, like
php_monotonic_timer_current(), etc.
- but aso, probably not all the symbols should be exported
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