aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/assert.h
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-06-29 16:39:22 +0200
committerGitHub <noreply@github.com>2019-06-29 16:39:22 +0200
commite2ce5ff9d6168de0ffaf59d6bf20f20631a34a2d (patch)
tree937e9bb7204b5ed160feba358a95d5e036cedc7c /src/nvim/assert.h
parent23a97949206bbe7dbbd3f7581bb2a24fabce116e (diff)
downloadrneovim-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/assert.h')
-rw-r--r--src/nvim/assert.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/assert.h b/src/nvim/assert.h
index 34734f294d..1361879876 100644
--- a/src/nvim/assert.h
+++ b/src/nvim/assert.h
@@ -133,8 +133,10 @@
/// Alternative for compilers without __builtin_xx_overflow ?
/// https://stackoverflow.com/a/44830670/152142
///
-/// @param MAX Maximum value of the narrowest type of operand.
-/// Not used if compiler supports __builtin_add_overflow.
+/// @param a Operand 1.
+/// @param b Operand 2.
+/// @param c Where to store the result.
+/// @param t Result type. Not used if compiler supports __builtin_add_overflow.
#ifdef HAVE_BUILTIN_ADD_OVERFLOW
# define STRICT_ADD(a, b, c, t) \
do { \
@@ -150,6 +152,7 @@
/// @def STRICT_SUB
/// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow.
+/// @see STRICT_ADD
#ifdef HAVE_BUILTIN_ADD_OVERFLOW
# define STRICT_SUB(a, b, c, t) \
do { \