diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-06-29 16:39:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-29 16:39:22 +0200 |
commit | e2ce5ff9d6168de0ffaf59d6bf20f20631a34a2d (patch) | |
tree | 937e9bb7204b5ed160feba358a95d5e036cedc7c /src/nvim/eval.c | |
parent | 23a97949206bbe7dbbd3f7581bb2a24fabce116e (diff) | |
download | rneovim-e2ce5ff9d6168de0ffaf59d6bf20f20631a34a2d.tar.gz rneovim-e2ce5ff9d6168de0ffaf59d6bf20f20631a34a2d.tar.bz2 rneovim-e2ce5ff9d6168de0ffaf59d6bf20f20631a34a2d.zip |
viml/profile: switch to uv_gettimeofday() #10356
Performance of high-resolution time (clock_gettime via uv_hrtime) is
expensive on some systems. For profiling VimL, syntax, etc., we don't
care about nanosecond-precision and monotonicity edge-cases, so avoid
uv_hrtime().
closes #10328
From the uv__hrtime() source:
https://github.com/libuv/libuv/blob/0cdb4a5b4b706d0e09413d9270da28f9a88dc083/src/unix/linux-core.c#L442-L462
/* Prefer CLOCK_MONOTONIC_COARSE if available but only when it has
* millisecond granularity or better. CLOCK_MONOTONIC_COARSE is
* serviced entirely from the vDSO, whereas CLOCK_MONOTONIC may
* decide to make a costly system call.
*/
This micro-benchmark (Debug build) shows negligible differences on my
system:
#include <sys/time.h>
...
proftime_T tm = profile_start();
int trials = 999999;
int64_t t = 0;
struct timeval tv;
for (int i = 0; i < trials; i++) {
t += gettimeofday(&tv,NULL);
}
tm = profile_end(tm);
ILOG("%d trials of gettimeofday: %s", trials, profile_msg(tm));
tm = profile_start();
for (int i = 0; i < trials; i++) {
t += os_hrtime();
}
tm = profile_end(tm);
ILOG("%d trials of os_hrtime: %s", trials, profile_msg(tm));
tm = profile_start();
for (int i = 0; i < trials; i++) {
t += os_utime();
}
tm = profile_end(tm);
ILOG("%d trials of os_utime: %s", trials, profile_msg(tm));
ILOG("%zu", t);
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ca2f4da22c..ddd2a06f4a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16536,7 +16536,7 @@ static void f_reltimefloat(typval_T *argvars , typval_T *rettv, FunPtr fptr) rettv->v_type = VAR_FLOAT; rettv->vval.v_float = 0; if (list2proftime(&argvars[0], &tm) == OK) { - rettv->vval.v_float = ((float_T)tm) / 1000000000; + rettv->vval.v_float = ((float_T)tm) / 1000000; } } |