Skip to content

Commit

Permalink
fix(stats): windows
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 2, 2023
1 parent 2ea0751 commit 85173dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/lazy/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ M.C = nil

function M.on_ui_enter()
M._stats.startuptime = M.track("UIEnter")
M._stats.startuptime_cputime = M.C.clock_gettime ~= nil
M._stats.startuptime_cputime = M.C ~= false
vim.cmd([[do User LazyVimStarted]])
end

Expand All @@ -33,6 +33,7 @@ end

function M.cputime()
if M.C == nil then
M.C = false
pcall(function()
ffi.cdef([[
typedef long time_t;
Expand All @@ -43,10 +44,12 @@ function M.cputime()
} nanotime;
int clock_gettime(clockid_t clk_id, struct timespec *tp);
]])
if M.C.clock_gettime then
M.C = ffi.C
end
end)
M.C = ffi.C
end
if M.C.clock_gettime then
if M.C then
local pnano = assert(ffi.new("nanotime[?]", 1))
local CLOCK_PROCESS_CPUTIME_ID = jit.os == "OSX" and 12 or 2
ffi.C.clock_gettime(CLOCK_PROCESS_CPUTIME_ID, pnano)
Expand Down

0 comments on commit 85173dc

Please sign in to comment.