From 77cb14cc6da5dff685c6e5a4005da433c39d5ff7 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 24 Apr 2018 00:27:09 +0200 Subject: API: nvim__stats() Use it to verify fsync() behavior. --- src/nvim/api/vim.c | 11 +++++++++++ src/nvim/globals.h | 5 +++++ src/nvim/os/fs.c | 1 + 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 07ec6e8c27..64fe1359c6 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1473,6 +1473,17 @@ Float nvim__id_float(Float flt) return flt; } +/// Gets internal stats. +/// +/// @return Map of various internal stats. +Dictionary nvim__stats(void) +{ + Dictionary rv = ARRAY_DICT_INIT; + PUT(rv, "fsync", INTEGER_OBJ(g_stats.fsync)); + PUT(rv, "redraw", INTEGER_OBJ(g_stats.redraw)); + return rv; +} + /// Gets a list of dictionaries representing attached UIs. /// /// @return Array of UI dictionaries diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 56790bc89b..403a5928c9 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -80,6 +80,11 @@ typedef enum { kTrue = 1, } TriState; +EXTERN struct nvim_stats_s { + int64_t fsync; + int64_t redraw; +} g_stats INIT(= { 0, 0 }); + /* Values for "starting" */ #define NO_SCREEN 2 /* no screen updating yet */ #define NO_BUFFERS 1 /* not all buffers loaded yet */ diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 0414794d01..3e1af7f1c2 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -629,6 +629,7 @@ int os_fsync(int fd) { int r; RUN_UV_FS_FUNC(r, uv_fs_fsync, fd, NULL); + g_stats.fsync++; return r; } -- cgit