diff options
author | AlexCai2019 <89138532+AlexCai2019@users.noreply.github.com> | 2022-05-08 01:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 01:43:28 +0800 |
commit | 0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch) | |
tree | be9790d9d4823fe728c5b36e94093fe5f42b7725 /test/full/self.lua | |
parent | 89203efad8c9b5513e05ca4d5696107924865b10 (diff) | |
parent | 67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff) | |
download | lua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip |
Merge branch 'sumneko:master' into master
Diffstat (limited to 'test/full/self.lua')
-rw-r--r-- | test/full/self.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/full/self.lua b/test/full/self.lua index 93cfe715..cfa6b710 100644 --- a/test/full/self.lua +++ b/test/full/self.lua @@ -5,11 +5,14 @@ local diag = require 'provider.diagnostic' local config = require 'config' local ws = require 'workspace' local guide = require 'parser.guide' +local vm = require 'vm' +local util = require 'utility' local path = ROOT / 'script' local uris = {} +files.reset() fsu.scanDirectory(path, function (path) if path:extension():string() ~= '.lua' then return @@ -47,3 +50,39 @@ end local passed = os.clock() - clock print('基准全量诊断用时:', passed) + +vm.clearNodeCache() + +local clock = os.clock() +local compileDatas = {} + +for uri in files.eachFile() do + local state = files.getState(uri) + local clock = os.clock() + guide.eachSource(state.ast, function (src) + vm.compileNode(src) + end) + compileDatas[uri] = { + passed = os.clock() - clock, + uri = uri, + } +end + +local printTexts = {} +for uri, data in util.sortPairs(compileDatas, function (a, b) + return compileDatas[a].passed > compileDatas[b].passed +end) do + printTexts[#printTexts+1] = ('全量编译耗时:%05.3f [%s]'):format(data.passed, uri) + if #printTexts >= 10 then + break + end +end + +util.revertTable(printTexts) + +for _, text in ipairs(printTexts) do + print(text) +end + +local passed = os.clock() - clock +print('基准全量编译用时:', passed) |