summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/test/full/example.lua24
-rw-r--r--server/test/full/init.lua1
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'