|
21 | 21 | #include "php_variables.h" |
22 | 22 | #include "zend_highlight.h" |
23 | 23 | #include "zend_portability.h" |
| 24 | +#include "zend_time.h" |
24 | 25 | #include "zend.h" |
25 | 26 | #include "ext/standard/basic_functions.h" |
26 | 27 | #include "ext/standard/info.h" |
|
46 | 47 | #include <sys/socket.h> |
47 | 48 | #include <arpa/inet.h> |
48 | 49 | #include <netinet/in.h> |
49 | | -#include <sys/time.h> |
50 | 50 |
|
51 | 51 | #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__) |
52 | 52 | #include "lscriu.c" |
@@ -1452,8 +1452,8 @@ int main( int argc, char * argv[] ) |
1452 | 1452 | char * php_bind = NULL; |
1453 | 1453 | int n; |
1454 | 1454 | int climode = 0; |
1455 | | - struct timeval tv_req_begin; |
1456 | | - struct timeval tv_req_end; |
| 1455 | + int64_t req_begin_ns, req_end_ns; |
| 1456 | + time_t req_end_sec; |
1457 | 1457 | int slow_script_msec = 0; |
1458 | 1458 | char time_buf[40]; |
1459 | 1459 |
|
@@ -1565,16 +1565,16 @@ int main( int argc, char * argv[] ) |
1565 | 1565 | } |
1566 | 1566 | #endif |
1567 | 1567 | if ( slow_script_msec ) { |
1568 | | - gettimeofday( &tv_req_begin, NULL ); |
| 1568 | + req_begin_ns = zend_monotime_fallback(); |
1569 | 1569 | } |
1570 | 1570 | ret = processReq(); |
1571 | 1571 | if ( slow_script_msec ) { |
1572 | | - gettimeofday( &tv_req_end, NULL ); |
1573 | | - n = ((long) tv_req_end.tv_sec - tv_req_begin.tv_sec ) * 1000 |
1574 | | - + (tv_req_end.tv_usec - tv_req_begin.tv_usec) / 1000; |
| 1572 | + req_end_ns = zend_monotime_fallback(); |
| 1573 | + n = (long) (req_end_ns - req_begin_ns) / 1000000; |
1575 | 1574 | if ( n > slow_script_msec ) |
1576 | 1575 | { |
1577 | | - strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &tv_req_end.tv_sec ) ); |
| 1576 | + req_end_sec = (time_t) (req_end_ns / ZEND_NANO_IN_SEC); |
| 1577 | + strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &req_end_sec ) ); |
1578 | 1578 | fprintf( stderr, "[%s] Slow PHP script: %d ms\n URL: %s %s\n Query String: %s\n Script: %s\n", |
1579 | 1579 | time_buf, n, LSAPI_GetRequestMethod(), |
1580 | 1580 | LSAPI_GetScriptName(), LSAPI_GetQueryString(), |
|
0 commit comments