Re: [PHP-DEV] Possible RFC: $_SERVER['REQUEST_TIME_FLOAT']

2023-04-12 Thread Rowan Tommins
On Wed, 12 Apr 2023 at 11:01, Herbert Groot Jebbink <
herb...@groot.jebbink.nl> wrote:

>
> I'm in the process of using hrtime(true) instead of microtime(true), for
> this it would be great if REQUEST_TIME_HR would also exist next to
> REQUEST_TIME and REQUEST_TIME_FLOAT



Hi :)

The idea sounds reasonable on the face of it.

Are there any performance issues calling hrtime on every request (possibly
platform-specific)?

I note that the existing values are not fetched directly from a time
source, but have some logic for SAPIs to provide a value [1] e.g. from the
Apache request context [2], and then REQUEST_TIME is just
REQUEST_TIME_FLOAT truncated to integer.

Should the same approach happen here? e.g. should all three values be based
on hrtime if the SAPI does not provide a value? Would we even need an extra
value if REQUEST_TIME_FLOAT had enough precision?

[1] https://heap.space/xref/php-src/main/SAPI.c?r=9d5f2f13#1085
[2]
https://heap.space/xref/php-src/sapi/apache2handler/sapi_apache2.c?r=4da0da7f#371

Regards,
-- 
Rowan Tommins
[IMSoP]


[PHP-DEV] Possible RFC: $_SERVER['REQUEST_TIME_FLOAT']

2023-04-12 Thread Herbert Groot Jebbink
Hello,

With this mail I want to do the first step of a RFC: "1. Email
internals@lists.php.net to measure reaction to your intended proposal."

I'm in the process of using hrtime(true) instead of microtime(true), for
this it would be great if REQUEST_TIME_HR would also exist next to
REQUEST_TIME and REQUEST_TIME_FLOAT

The implementation can be done with adding below 2 lines to
main/php_variables.c where REQUEST_TIME and REQUEST_TIME_FLOAT are also
defined.

ZVAL_LONG(, php_hrtime_current());
php_register_variable_quick("REQUEST_TIME_HR", sizeof("REQUEST_TIME_HR")-1,
, ht);

With Kind Regards, Herbert