Skip to content

Commit

Permalink
[lua] improved lua profiling support via tz.profzone_obj
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed Nov 20, 2023
1 parent caa4475 commit 780174b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/tz/lua/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,39 @@ namespace tz::lua
tz::io::lua_initialise(s);
tz::ren::lua_initialise(s);
tz::wsi::lua_initialise(s);

s.execute(R"(
tz.profzone_obj = {}
function tz.profzone_obj:new(o)
o = o or {}
setmetatable(o, self)
self.__close = function()
tracy.ZoneEnd()
end
self.__index = self
tracy.ZoneBegin()
return o
end
function tz.profzone_obj:set_text(txt)
tracy.ZoneText(txt)
end
function tz.profzone_obj:set_name(name)
tracy.ZoneName(name)
end
tz.create_profiling_object = function()
local obj = {}
setmetatable(obj, {
__close = function()
tracy.ZoneEnd()
end
})
tracy.ZoneBeginN("unnamed profzone")
return obj
end
)");
}
}
6 changes: 5 additions & 1 deletion src/tz/lua/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,11 @@ namespace tz::lua
ZoneEnd = function()
end,
ZoneBeginN = function()
end
end,
ZoneName = function()
end,
ZoneText = function()
end,
}
)");
#endif
Expand Down

0 comments on commit 780174b

Please sign in to comment.