|
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" |
@@ -1450,8 +1450,8 @@ int main( int argc, char * argv[] ) |
1450 | 1450 | char * php_bind = NULL; |
1451 | 1451 | int n; |
1452 | 1452 | int climode = 0; |
1453 | | - struct timeval tv_req_begin; |
1454 | | - struct timeval tv_req_end; |
| 1453 | + int64_t req_begin_ns, req_end_ns; |
| 1454 | + time_t req_end_sec; |
1455 | 1455 | int slow_script_msec = 0; |
1456 | 1456 | char time_buf[40]; |
1457 | 1457 |
|
@@ -1563,16 +1563,16 @@ int main( int argc, char * argv[] ) |
1563 | 1563 | } |
1564 | 1564 | #endif |
1565 | 1565 | if ( slow_script_msec ) { |
1566 | | - gettimeofday( &tv_req_begin, NULL ); |
| 1566 | + req_begin_ns = zend_monotime_fallback(); |
1567 | 1567 | } |
1568 | 1568 | ret = processReq(); |
1569 | 1569 | if ( slow_script_msec ) { |
1570 | | - gettimeofday( &tv_req_end, NULL ); |
1571 | | - n = ((long) tv_req_end.tv_sec - tv_req_begin.tv_sec ) * 1000 |
1572 | | - + (tv_req_end.tv_usec - tv_req_begin.tv_usec) / 1000; |
| 1570 | + req_end_ns = zend_monotime_fallback(); |
| 1571 | + n = (long) (req_end_ns - req_begin_ns) / 1000000; |
1573 | 1572 | if ( n > slow_script_msec ) |
1574 | 1573 | { |
1575 | | - strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &tv_req_end.tv_sec ) ); |
| 1574 | + req_end_sec = (time_t) (req_end_ns / ZEND_NANO_IN_SEC); |
| 1575 | + strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &req_end_sec ) ); |
1576 | 1576 | fprintf( stderr, "[%s] Slow PHP script: %d ms\n URL: %s %s\n Query String: %s\n Script: %s\n", |
1577 | 1577 | time_buf, n, LSAPI_GetRequestMethod(), |
1578 | 1578 | LSAPI_GetScriptName(), LSAPI_GetQueryString(), |
|
0 commit comments