Skip to content

Commit cd23038

Browse files
committed
#1192 add benchmark for completion jass.common
1 parent ec39447 commit cd23038

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

script/lclient.lua

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function mt:registerFakers()
211211
'workspace/diagnostic/refresh',
212212
'window/workDoneProgress/create',
213213
'window/showMessage',
214+
'window/showMessageRequest',
214215
'window/logMessage',
215216
} do
216217
self:register(method, function ()

test/tclient/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ require 'tclient.tests.folders-with-single-file'
55
require 'tclient.tests.load-library'
66
require 'tclient.tests.files-associations'
77
require 'tclient.tests.resolve-completion'
8+
require 'tclient.tests.performance-1'

test/tclient/tests/performance-1.lua

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
local lclient = require 'lclient'
2+
local util = require 'utility'
3+
local ws = require 'workspace'
4+
local files = require 'files'
5+
local furi = require 'file-uri'
6+
local fs = require 'bee.filesystem'
7+
local await = require 'await'
8+
9+
---@async
10+
lclient():start(function (client)
11+
client:registerFakers()
12+
13+
client:register('workspace/configuration', function ()
14+
return {
15+
{
16+
['workspace.library'] = { '${3rd}/Jass/library' }
17+
},
18+
}
19+
end)
20+
21+
client:initialize()
22+
23+
ws.awaitReady()
24+
25+
local text = [[
26+
local jass = require 'jass.common'
27+
28+
]]
29+
30+
local clock = os.clock()
31+
32+
client:awaitRequest('textDocument/didOpen', {
33+
textDocument = {
34+
uri = furi.encode('abc/performance-1.lua'),
35+
languageId = 'lua',
36+
version = 0,
37+
text = text,
38+
}
39+
})
40+
41+
await.sleep(1.0)
42+
43+
for c in ('jass'):gmatch '.' do
44+
text = text .. c
45+
client:awaitRequest('textDocument/didChange', {
46+
textDocument = {
47+
uri = furi.encode('abc/performance-1.lua'),
48+
},
49+
contentChanges = {
50+
{
51+
text = text,
52+
}
53+
}
54+
})
55+
await.sleep(1.0)
56+
end
57+
58+
local items = client:awaitRequest('textDocument/completion', {
59+
textDocument = { uri = furi.encode('abc/performance-1.lua') },
60+
position = { line = 2, character = 4 },
61+
})
62+
local item = client:awaitRequest('completionItem/resolve', items.items[1])
63+
64+
assert(item.documentation ~= nil)
65+
66+
print(('Benchmark [performance-1] takes [%.3f] sec.'):format(os.clock() - clock))
67+
end)

0 commit comments

Comments
 (0)