diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 23:51:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 23:51:56 +0800 |
commit | 04728c31bf2e64d92e5944ecf5d41616bf3c9ae6 (patch) | |
tree | 06762ec8a7be0687d96467d989e33547b1bce479 /test/full/self.lua | |
parent | 29f8cfda90fa24acd93b57fdaa1df9eea9dfd3d9 (diff) | |
download | lua-language-server-04728c31bf2e64d92e5944ecf5d41616bf3c9ae6.zip |
add some tests
Diffstat (limited to 'test/full/self.lua')
-rw-r--r-- | test/full/self.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/full/self.lua b/test/full/self.lua index 93cfe715..6c7b302d 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,38 @@ end local passed = os.clock() - clock print('基准全量诊断用时:', passed) + +vm.clearNodeCache() + +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) |