Hi Niklas,

> -----Original Message-----
> From: Niklas Keller [mailto:m...@kelunik.com]
> Sent: Sunday, February 5, 2017 8:19 PM
> To: Anatol Belski <anatol....@belski.net>
> Cc: Leigh <lei...@gmail.com>; Michael Wallner <m...@php.net>; PHP Internals
> <internals@lists.php.net>; Bob Weinand <bwo...@php.net>; Daniel Lowrey
> <rdlow...@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



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to