diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/service.lua | 6 | ||||
-rw-r--r-- | server/src/vm/chain.lua | 5 | ||||
-rw-r--r-- | server/src/vm/value.lua | 5 |
3 files changed, 13 insertions, 3 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 2e7f43b9..ade3b2eb 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -806,20 +806,20 @@ function mt:listen() local _, out = async.run 'proto' self._proto = out - local clock = os.clock() + local timerClock = 0.0 while true do local startClock = os.clock() - local delta = os.clock() - clock async.onTick() self:onTick() + local delta = os.clock() - timerClock local suc, err = xpcall(updateTimer, log.error, delta) if not suc then io.stderr:write(err) io.stderr:flush() end + timerClock = os.clock() - clock = os.clock() local passedClock = os.clock() - startClock if passedClock > 0.1 then thread.sleep(0.0) diff --git a/server/src/vm/chain.lua b/server/src/vm/chain.lua index 7d56e1bf..a8ff01fa 100644 --- a/server/src/vm/chain.lua +++ b/server/src/vm/chain.lua @@ -13,6 +13,7 @@ function mt:clearCache() if self.count <= self.max then return end + local clock = os.clock() local n = 0 for uri, value in pairs(self.cache) do local ok = value:eachInfo(function () @@ -30,6 +31,10 @@ function mt:clearCache() if self.max < self.min then self.max = self.min end + local passed = os.clock() - clock + if passed > 0.1 then + log.warn(('chain:clearCache takes: [%.3f]sec, self.count: %d'):format(passed, self.count)) + end end function mt:get(uri) diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 9ffd55bc..7eb7784e 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -410,6 +410,7 @@ function mt:addInfo(tp, source, ...) end function mt:eachInfo(callback) + local clock = os.clock() local infos = self._info local list = {} for srcId, info in pairs(infos) do @@ -426,6 +427,10 @@ function mt:eachInfo(callback) table.sort(list, function (a, b) return a._sort < b._sort end) + local passed = os.clock() - clock + if passed > 0.1 then + log.warn(('eachInfo takes: [%.3f]sec, #list: %d'):format(passed, #list)) + end for i = 1, #list do local info = list[i] local res = callback(info, listMgr.get(info.source)) |