summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/global-manager.lua10
-rw-r--r--script/vm/local-id.lua5
2 files changed, 15 insertions, 0 deletions
diff --git a/script/vm/global-manager.lua b/script/vm/global-manager.lua
index 9752621e..9713856e 100644
--- a/script/vm/global-manager.lua
+++ b/script/vm/global-manager.lua
@@ -240,6 +240,7 @@ function m.getFields(cate, name)
local key = cate .. '|' .. name
-- TODO: optimize
+ local clock = os.clock()
for gid, global in pairs(m.globals) do
if gid ~= key
and util.stringStartWith(gid, key)
@@ -248,6 +249,10 @@ function m.getFields(cate, name)
globals[#globals+1] = global
end
end
+ local cost = os.clock() - clock
+ if cost > 0.1 then
+ log.warn('global-manager getFields cost %.3f', cost)
+ end
return globals
end
@@ -258,12 +263,17 @@ function m.getGlobals(cate)
local globals = {}
-- TODO: optimize
+ local clock = os.clock()
for gid, global in pairs(m.globals) do
if util.stringStartWith(gid, cate)
and not gid:find(m.ID_SPLITE) then
globals[#globals+1] = global
end
end
+ local cost = os.clock() - clock
+ if cost > 0.1 then
+ log.warn('global-manager getGlobals cost %.3f', cost)
+ end
return globals
end
diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua
index cda49d23..aa4f3118 100644
--- a/script/vm/local-id.lua
+++ b/script/vm/local-id.lua
@@ -177,6 +177,7 @@ function m.getFields(source)
return nil
end
-- TODOļ¼šoptimize
+ local clock = os.clock()
local fields = {}
for lid, sources in pairs(root._localIDs) do
if lid ~= id
@@ -189,6 +190,10 @@ function m.getFields(source)
end
end
end
+ local cost = os.clock() - clock
+ if cost > 1.0 then
+ log.warn('local-id getFields takes %.3f seconds', cost)
+ end
return fields
end