diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-15 17:29:02 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-15 17:29:02 +0800 |
commit | c8e51355694ea523ebfbf34c576868c6c59c166c (patch) | |
tree | 0e4533554c9b0e22ff490e0dde3ad67bb73ce769 /server/test | |
parent | 66ab0517b0ca771fdfb92af87f2bfb8216a13777 (diff) | |
download | lua-language-server-c8e51355694ea523ebfbf34c576868c6c59c166c.zip |
诊断耗时测试
Diffstat (limited to 'server/test')
-rw-r--r-- | server/test/full/example.lua | 24 | ||||
-rw-r--r-- | server/test/full/init.lua | 1 |
2 files changed, 22 insertions, 3 deletions
diff --git a/server/test/full/example.lua b/server/test/full/example.lua index 2a84de2a..a096f83d 100644 --- a/server/test/full/example.lua +++ b/server/test/full/example.lua @@ -1,4 +1,6 @@ local fs = require 'bee.filesystem' +local core = require 'core' +local parser = require 'parser' TEST(io.load(ROOT / 'src' / 'vm' / 'vm.lua')) @@ -6,18 +8,34 @@ TEST(io.load(ROOT / 'src' / 'vm' / 'vm.lua')) local function testIfExit(path) local buf = io.load(fs.path(path)) if buf then + local vm + + local clock = os.clock() + local max = 100 + local need + for i = 1, max do + vm = TEST(buf) + local passed = os.clock() - clock + if passed >= 1.0 or i == max then + need = passed / i + break + end + end + print(('基准编译测试[%s]单次耗时:%.10f'):format(path:filename():string(), need)) + local clock = os.clock() local max = 100 local need + local lines = parser:lines(buf, 'utf8') for i = 1, max do - TEST(buf) + core.diagnostics(vm, lines, 'test') local passed = os.clock() - clock - if (passed >= 1.0 and i >= 3) or i == max then + if passed >= 1.0 or i == max then need = passed / i break end end - print(('基准测试[%s]单次耗时:%.10f'):format(path:filename():string(), need)) + print(('基准诊断测试[%s]单次耗时:%.10f'):format(path:filename():string(), need)) end end testIfExit(ROOT / 'test' / 'example' / 'vm.txt') diff --git a/server/test/full/init.lua b/server/test/full/init.lua index 342ac331..808d7db3 100644 --- a/server/test/full/init.lua +++ b/server/test/full/init.lua @@ -8,6 +8,7 @@ function TEST(script) assert(ast) local vm, err = buildVM(ast) assert(vm, err) + return vm end require 'full.normal' |