From dc913974638af5ba4b0d76bcb3b0efd838bf30a1 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 16 Apr 2016 17:15:51 +0200 Subject: vim-patch:7.4.1285 Problem: Cannot measure elapsed time. Solution: Add reltimefloat(). https://github.com/vim/vim/commit/79c2c881bb7ae1cbdeeff91d4875b4bf2e54df06 Applied manually. None of the ifdef's applies anymore, and proftime_T was changed into an uint64_T, so the function profile_float to convert proftime_T to float is not needed in nvim. --- src/nvim/eval.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d84bdfebfe..16a96ba29e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6850,6 +6850,7 @@ static struct fst { { "range", 1, 3, f_range }, { "readfile", 1, 3, f_readfile }, { "reltime", 0, 2, f_reltime }, + { "reltimefloat", 1, 1, f_reltimefloat }, { "reltimestr", 1, 1, f_reltimestr }, { "remove", 2, 3, f_remove }, { "rename", 2, 2, f_rename }, @@ -15296,6 +15297,21 @@ static void f_uniq(typval_T *argvars, typval_T *rettv) do_sort_uniq(argvars, rettv, false); } +// +// "reltimefloat()" function +// +static void f_reltimefloat(typval_T *argvars , typval_T *rettv) + FUNC_ATTR_NONNULL_ALL +{ + proftime_T tm; + + rettv->v_type = VAR_FLOAT; + rettv->vval.v_float = 0; + if (list2proftime(&argvars[0], &tm) == OK) { + rettv->vval.v_float = ((float_T)tm) / 1000000000; + } +} + /* * "soundfold({word})" function */ -- cgit