elseif what == 'tail return' then
local now = clock()
data[key] = data[key] + (now - table.remove(stack))
end
Is this a bug? In Lua 5.2 at least, it looks like the 'what' value when reporting a tail call/return is 'tail call' not 'tail return'.
My understanding is that tail calls are a bit tricky to instrument -- because a 'tail call' is actually one event that's simultaneously both a call and a return.
I think that, when instrumenting for inclusive call time, ignoring tail call events entirely is actually a sensible policy. Effectively, I think that's what your code is doing (as the 'tail return' case will never be hit).