Skip to content

Commit 85173dc

Browse files
committed
fix(stats): windows
1 parent 2ea0751 commit 85173dc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/lazy/stats.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ M.C = nil
2121

2222
function M.on_ui_enter()
2323
M._stats.startuptime = M.track("UIEnter")
24-
M._stats.startuptime_cputime = M.C.clock_gettime ~= nil
24+
M._stats.startuptime_cputime = M.C ~= false
2525
vim.cmd([[do User LazyVimStarted]])
2626
end
2727

@@ -33,6 +33,7 @@ end
3333

3434
function M.cputime()
3535
if M.C == nil then
36+
M.C = false
3637
pcall(function()
3738
ffi.cdef([[
3839
typedef long time_t;
@@ -43,10 +44,12 @@ function M.cputime()
4344
} nanotime;
4445
int clock_gettime(clockid_t clk_id, struct timespec *tp);
4546
]])
47+
if M.C.clock_gettime then
48+
M.C = ffi.C
49+
end
4650
end)
47-
M.C = ffi.C
4851
end
49-
if M.C.clock_gettime then
52+
if M.C then
5053
local pnano = assert(ffi.new("nanotime[?]", 1))
5154
local CLOCK_PROCESS_CPUTIME_ID = jit.os == "OSX" and 12 or 2
5255
ffi.C.clock_gettime(CLOCK_PROCESS_CPUTIME_ID, pnano)

0 commit comments

Comments
 (0)