File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change
1
+ local uv = vim .loop
2
+
1
3
local M = {
2
4
config = nil ,
3
5
path = nil ,
21
23
22
24
--- Write to log file via M.line
23
25
--- START is prefixed
24
- --- @return reltime to pass to profile_end
26
+ --- @return nanos to pass to profile_end
25
27
function M .profile_start (fmt , ...)
28
+ if not M .path or not M .config .types .profile and not M .config .types .all then
29
+ return
30
+ end
26
31
M .line (" profile" , " START " .. (fmt or " ???" ), ... )
27
- return vim . fn . reltime ()
32
+ return uv . hrtime ()
28
33
end
29
34
30
35
--- Write to log file via M.line
31
36
--- END is prefixed and duration in seconds is suffixed
32
- --- @param start reltime returned from profile_start
37
+ --- @param start nanos returned from profile_start
33
38
function M .profile_end (start , fmt , ...)
34
- local dur = vim .fn .reltimestr (vim .fn .reltime (start , vim .fn .reltime ()))
35
- M .line (" profile" , " END " .. (fmt or " ???" ) .. " " .. dur .. " s" , ... )
39
+ if not M .path or not M .config .types .profile and not M .config .types .all then
40
+ return
41
+ end
42
+ local millis = start and math.modf ((uv .hrtime () - start ) / 1000000 ) or - 1
43
+ M .line (" profile" , " END " .. (fmt or " ???" ) .. " " .. millis .. " ms" , ... )
36
44
end
37
45
38
46
-- Write to log file via M.raw
You can’t perform that action at this time.
0 commit comments