Req #68029 [Com]: PHP and monotonic date time
| From: | roberto at spadim dot com dot br | Date: | Tue, 16 Sep 2014 16:16:25 +0000 |
| Subject: | Req #68029 [Com]: PHP and monotonic date time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187549@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68029&edit=1
ID: 68029
Comment by: roberto at spadim dot com dot br
Reported by: roberto at spadim dot com dot br
Summary: PHP and monotonic date time
Status: Open
Type: Feature/Change Request
Package: Date/time related
Operating System: any
PHP Version: 5.6.1RC1
Block user comment: N
Private report: N
New Comment:
example with linux clock_gettime
https://github.com/php/php-src/blob/128eda843f7dff487fff529a384fee3c5494e0f6/sapi/fpm/fpm/fpm_clock.c
Previous Comments:
------------------------------------------------------------------------
[2014-09-16 16:14:48] roberto at spadim dot com dot br
functions to be used
http://tdistler.com/2010/06/27/high-performance-timing-on-linux-windows
linux: int clock_gettime(clockid_t clock_id, struct timespec *tp);
http://pubs.opengroup.org/onlinepubs/000095399/functions/clock_getres.html
windows: BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER lpPerformanceCount);
http://msdn.microsoft.com/en-us/library/ms644904(v=VS.85).aspx
------------------------------------------------------------------------
[2014-09-16 16:07:39] roberto at spadim dot com dot br
Description:
------------
Hi guys i didn't found a monotonic clock function
for example:
<?php
system("date -s \"2014-09-16 13:01:00 BRT\"");sleep(1);
echo microtime(1)."\n";
system("date -s \"2014-09-16 13:01:00 BRT\"");
echo microtime(1)."\n";
?>
this script output
# php date.php
Tue Sep 16 13:01:00 BRT 2014
1410883261.0003
Tue Sep 16 13:01:00 BRT 2014
1410883260.0002
the clock is ok since i changed the date time, but, how to use a monotonic clock? i just found
clock_gettime() using CLOCK_MONOTONIC with FPM (php-src/sapi/fpm/fpm/fpm_clock.c), but it don't
export functions to php script space, maybe we could implement a monotonic clock function?
Test script:
---------------
<?php
system("date -s \"2014-09-16 13:01:00 BRT\"");sleep(1);
echo microtime(1)."\n";
system("date -s \"2014-09-16 13:01:00 BRT\"");
echo microtime(1)."\n";
?>
Expected result:
----------------
correct output, since it's a feature request
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68029&edit=1