0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 9.0.1411: accuracy of profiling is not optimal

Problem:    Accuracy of profiling is not optimal.
Solution:   Use CLOCK_MONOTONIC if possible. (Ernie Rael, closes #12129)
This commit is contained in:
Ernie Rael
2023-03-16 21:43:15 +00:00
committed by Bram Moolenaar
parent 16110ccf11
commit 076de79ad8
9 changed files with 91 additions and 49 deletions

View File

@@ -1869,8 +1869,27 @@ typedef void *vim_acl_T; // dummy to pass an ACL to a function
#if (defined(FEAT_PROFILE) || defined(FEAT_RELTIME)) && !defined(PROTO)
# ifdef MSWIN
typedef LARGE_INTEGER proftime_T;
# define PROF_TIME_BLANK " "
# define PROF_TOTALS_HEADER "count total (s) self (s)"
# else
// Use tv_fsec for fraction of second (micro or nano) of proftime_T
# if defined(HAVE_TIMER_CREATE)
typedef struct timespec proftime_T;
# define PROF_GET_TIME(tm) clock_gettime(CLOCK_MONOTONIC, tm)
# define tv_fsec tv_nsec
# define TV_FSEC_SEC 1000000000L
# define PROF_TIME_FORMAT "%3ld.%09ld"
# define PROF_TIME_BLANK " "
# define PROF_TOTALS_HEADER "count total (s) self (s)"
# else
typedef struct timeval proftime_T;
# define PROF_GET_TIME(tm) gettimeofday(tm, NULL)
# define tv_fsec tv_usec
# define TV_FSEC_SEC 1000000
# define PROF_TIME_FORMAT "%3ld.%06ld"
# define PROF_TIME_BLANK " "
# define PROF_TOTALS_HEADER "count total (s) self (s)"
# endif
# endif
#else
typedef int proftime_T; // dummy for function prototypes