Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/tools/profiler-mhf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ function Instrumentator:create_hook()

local function _write(id, depth)
if self.function_stack[func][depth] == nil then
-- TODO: There is probably an issue with clculating the tail calls
-- TODO: There is probably an issue with calculating the tail calls
-- depth here. Need to investigate further.
return
end

local name = info.name or string.format("%s(%s:%s)", id, info.short_src, info.linedefined)
local start_time = self.function_stack[func][depth]
local end_time = self.clock() - start_time

-- Avoid 0 values for end_time as it can get interpreted as "forever"
if end_time < 1 then end_time = 1 end

self.profile:write_item(name, start_time, end_time)
self.function_stack[func][depth] = nil
end
Expand All @@ -118,7 +122,7 @@ function Instrumentator:create_hook()

_write("unknown", stack_depth)

-- Cleanup
-- Clean-up
if next(self.function_stack[func]) == nil then
self.function_stack[func] = nil
end
Expand Down Expand Up @@ -151,8 +155,11 @@ function Instrumentator:scope(name)
local scope_name = string.format("%s(%s:%s)", name, info.short_src, info.linedefined)
local start_time = self.scope_stack[name]
local end_time = self.clock() - start_time
self.profile:write_item(scope_name, start_time, end_time)

-- Avoid 0 values for end_time as it can get interpreted as "forever"
if end_time < 1 then end_time = 1 end

self.profile:write_item(scope_name, start_time, end_time)
self.scope_stack[name] = nil
end

Expand Down
Loading