summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-04 00:31:14 +0800
committerruki <[email protected]>2021-05-04 00:31:14 +0800
commit77b05dde3e72e0b3b02bb31091ea176b18680742 (patch)
treeb5ec1759fd731ea0b2bae7fdbfdb952bca2846d7
parent9016206b87381de0eb68f857a52bb910e9c077d0 (diff)
improve profiler handler
-rw-r--r--xmake/core/base/profiler.lua21
1 files changed, 1 insertions, 20 deletions
diff --git a/xmake/core/base/profiler.lua b/xmake/core/base/profiler.lua
index fd0e253c3..51f3a9172 100644
--- a/xmake/core/base/profiler.lua
+++ b/xmake/core/base/profiler.lua
@@ -125,25 +125,13 @@ end
-- the tracing handler
function profiler._tracing_handler(hooktype)
-
- -- the function info
- local funcinfo = debug.getinfo(2, 'nS')
-
- -- is call?
if hooktype == "call" then
-
- -- is xmake function?
+ local funcinfo = debug.getinfo(2, 'nS')
local name = funcinfo.name
local source = funcinfo.short_src or 'C_FUNC'
if name and os.isfile(source) then
-
- -- the function line
local line = string.format("%d", funcinfo.linedefined or 0)
-
- -- get the relative source
source = path.relative(source, xmake._PROGRAM_DIR)
-
- -- trace it
utils.print("%-30s: %s: %s", name, source, line)
end
end
@@ -151,20 +139,13 @@ end
-- start profiling
function profiler:start()
-
- -- trace?
local mode = self:mode()
if mode and mode == "trace" then
debug.sethook(profiler._tracing_handler, 'cr', 0)
else
- -- init reports
self._REPORTS = {}
self._REPORTS_BY_TITLE = {}
-
- -- save the start time
self._STARTIME = os.clock()
-
- -- start to hook
debug.sethook(profiler._profiling_handler, 'cr', 0)
end
end