diff options
| author | ruki <[email protected]> | 2022-10-28 22:38:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-10-28 22:38:12 +0800 |
| commit | 2dcbc30142e15588356974067c36e377c72b7dd1 (patch) | |
| tree | b63db621dfbf606f80bdcc4b03ac94caf28280c1 /xmake/core/base/scheduler.lua | |
| parent | dedb33d508aa6582d24674d108466b2bdbf5c9d8 (diff) | |
improve profiler
Diffstat (limited to 'xmake/core/base/scheduler.lua')
| -rw-r--r-- | xmake/core/base/scheduler.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index ae8014dce..fe6522cad 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -360,6 +360,18 @@ function scheduler:_co_groups_resume() return resumed_count end +-- get profiler +function scheduler:_profiler() + local profiler = self._PROFILE + if profiler == nil then + profiler = require("base/profiler") + if not profiler:enabled() then + profiler = false + end + end + return profiler or nil +end + -- start a new coroutine task function scheduler:co_start(cotask, ...) return self:co_start_named(nil, cotask, ...) @@ -383,6 +395,10 @@ function scheduler:co_start_withopt(opt, cotask, ...) -- start coroutine local co co = _coroutine.new(coname, coroutine.create(function(...) + local profiler = self:_profiler() + if profiler and profiler:enabled() then + profiler:start() + end self:_co_curdir_update() self:_co_curenvs_update() cotask(...) |
