Skip to content

Commit 251f743

Browse files
committed
add logs
1 parent 38c34dd commit 251f743

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"type": "lua",
2727
"request": "attach",
2828
"stopOnEntry": false,
29-
"address": "127.0.0.1:11413",
29+
"address": "127.0.0.1:11429",
3030
"outputCapture": [
3131
],
3232
"sourceMaps": [

script/provider/provider.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ m.register '$/didChangeVisibleRanges' {
998998
m.register '$/status/click' {
999999
---@async
10001000
function ()
1001-
-- TODO: translate
10021001
local titleDiagnostic = lang.script.WINDOW_LUA_STATUS_DIAGNOSIS_TITLE
10031002
local result = client.awaitRequestMessage('Info', lang.script.WINDOW_LUA_STATUS_DIAGNOSIS_MSG, {
10041003
titleDiagnostic,

script/vm/global-manager.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ function m.getFields(cate, name)
240240
local key = cate .. '|' .. name
241241

242242
-- TODO: optimize
243+
local clock = os.clock()
243244
for gid, global in pairs(m.globals) do
244245
if gid ~= key
245246
and util.stringStartWith(gid, key)
@@ -248,6 +249,10 @@ function m.getFields(cate, name)
248249
globals[#globals+1] = global
249250
end
250251
end
252+
local cost = os.clock() - clock
253+
if cost > 0.1 then
254+
log.warn('global-manager getFields cost %.3f', cost)
255+
end
251256

252257
return globals
253258
end
@@ -258,12 +263,17 @@ function m.getGlobals(cate)
258263
local globals = {}
259264

260265
-- TODO: optimize
266+
local clock = os.clock()
261267
for gid, global in pairs(m.globals) do
262268
if util.stringStartWith(gid, cate)
263269
and not gid:find(m.ID_SPLITE) then
264270
globals[#globals+1] = global
265271
end
266272
end
273+
local cost = os.clock() - clock
274+
if cost > 0.1 then
275+
log.warn('global-manager getGlobals cost %.3f', cost)
276+
end
267277

268278
return globals
269279
end

script/vm/local-id.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ function m.getFields(source)
177177
return nil
178178
end
179179
-- TODO:optimize
180+
local clock = os.clock()
180181
local fields = {}
181182
for lid, sources in pairs(root._localIDs) do
182183
if lid ~= id
@@ -189,6 +190,10 @@ function m.getFields(source)
189190
end
190191
end
191192
end
193+
local cost = os.clock() - clock
194+
if cost > 1.0 then
195+
log.warn('local-id getFields takes %.3f seconds', cost)
196+
end
192197
return fields
193198
end
194199

0 commit comments

Comments
 (0)