diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-10 17:40:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-10 17:40:28 +0800 |
commit | 79c87da843cb747db1886e706aa0c22e85e1c46d (patch) | |
tree | 681c10da07441222a8c736015e0bc18dbbe3d4e6 /script-beta/await.lua | |
parent | 3032729867c8975d433adc5de11cdc905d9fc2eb (diff) | |
download | lua-language-server-79c87da843cb747db1886e706aa0c22e85e1c46d.zip |
追踪一下高耗时的单步
Diffstat (limited to 'script-beta/await.lua')
-rw-r--r-- | script-beta/await.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua index 38fb6548..7134716b 100644 --- a/script-beta/await.lua +++ b/script-beta/await.lua @@ -80,13 +80,36 @@ function m.delay(getVersion) return coroutine.yield() end +local function buildInfo(waker) + local co + for i = 1, 100 do + local n, v = debug.getupvalue(waker, i) + if not n then + return nil + end + if n == 'co' then + co = v + break + end + end + if not co then + return nil + end + return debug.traceback(co) +end + --- 步进 function m.step() local waker = m.delayQueue[m.delayQueueIndex] if waker then m.delayQueue[m.delayQueueIndex] = false m.delayQueueIndex = m.delayQueueIndex + 1 + local clock = os.clock() waker() + local passed = os.clock() - clock + if passed > 0.01 then + log.warn(('Await step takes [%.3f] sec.\n%s'):format(passed, buildInfo(waker))) + end return true else m.delayQueue = {} |