diff options
Diffstat (limited to 'test/full')
-rw-r--r-- | test/full/init.lua | 13 | ||||
-rw-r--r-- | test/full/self.lua | 39 |
2 files changed, 50 insertions, 2 deletions
diff --git a/test/full/init.lua b/test/full/init.lua index e83a7d6d..3b1d2fe2 100644 --- a/test/full/init.lua +++ b/test/full/init.lua @@ -27,8 +27,17 @@ require 'full.dirty' require 'full.projects' require 'full.self' +local times = {} for name, time in util.sortPairs(DIAGTIMES, function (k1, k2) - return DIAGTIMES[k1] < DIAGTIMES[k2] + return DIAGTIMES[k1] > DIAGTIMES[k2] end) do - print('诊断任务耗时:', name, time) + times[#times+1] = ('诊断任务耗时:%05.3f [%s]'):format(time, name) + if #times >= 10 then + break + end +end + +util.revertTable(times) +for _, time in ipairs(times) do + print(time) end 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) |