File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,8 @@ static inline void hp_array_del(char **name_array);
224224char * hp_get_trace_callback (char * symbol , zend_execute_data * data );
225225void hp_init_trace_callbacks ();
226226
227+ double get_timebase_conversion ();
228+
227229hp_ignored_functions * hp_ignored_functions_init (char * * names );
228230
229231/* Struct to hold the various callbacks for a single xhprof mode */
@@ -286,6 +288,8 @@ ZEND_BEGIN_MODULE_GLOBALS(xhprof)
286288 /* Table of ignored function names and their filter */
287289 hp_ignored_functions * ignored_functions ;
288290
291+ double timebase_conversion ;
292+
289293ZEND_END_MODULE_GLOBALS (xhprof )
290294
291295PHP_MINIT_FUNCTION (xhprof );
Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ PHP_RINIT_FUNCTION(xhprof)
299299 ZEND_TSRMLS_CACHE_UPDATE ();
300300#endif
301301
302+ XHPROF_G (timebase_conversion ) = get_timebase_conversion ();
303+
302304 return SUCCESS ;
303305}
304306
@@ -401,6 +403,18 @@ void hp_ignored_functions_clear(hp_ignored_functions *functions)
401403 efree (functions );
402404}
403405
406+ double get_timebase_conversion ()
407+ {
408+ #if defined(__APPLE__ )
409+ mach_timebase_info_data_t info ;
410+ (void ) mach_timebase_info (& info );
411+
412+ return (info .numer / info .denom ) * 1000 * 1000 ;
413+ #endif
414+
415+ return 1.0 ;
416+ }
417+
404418hp_ignored_functions * hp_ignored_functions_init (char * * names )
405419{
406420 /* Delete the array storing ignored function names */
@@ -838,7 +852,7 @@ void hp_sample_check(hp_entry_t **entries)
838852static inline uint64 cycle_timer ()
839853{
840854#if defined(__APPLE__ ) && defined(__MACH__ )
841- return mach_absolute_time ();
855+ return mach_absolute_time () / XHPROF_G ( timebase_conversion ) ;
842856#else
843857 struct timespec s ;
844858 clock_gettime (CLOCK_MONOTONIC , & s );
You can’t perform that action at this time.
0 commit comments