summaryrefslogtreecommitdiff
path: root/test/full/self.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/full/self.lua')
-rw-r--r--test/full/self.lua39
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)