summaryrefslogtreecommitdiff
path: root/test/tclient
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-07 19:28:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-07 19:28:05 +0800
commitcd23038c3f7d7fd8533c451e2ec2b33febd31934 (patch)
tree89f7450913e5c606baab02217a1eb33442a79a4b /test/tclient
parentec394477507fc4e39a3280fb28bf6613b6f69c2a (diff)
downloadlua-language-server-cd23038c3f7d7fd8533c451e2ec2b33febd31934.zip
#1192 add benchmark for completion `jass.common`
Diffstat (limited to 'test/tclient')
-rw-r--r--test/tclient/init.lua1
-rw-r--r--test/tclient/tests/performance-1.lua67
2 files changed, 68 insertions, 0 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index 9e1db8d4..d2b86604 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -5,3 +5,4 @@ require 'tclient.tests.folders-with-single-file'
require 'tclient.tests.load-library'
require 'tclient.tests.files-associations'
require 'tclient.tests.resolve-completion'
+require 'tclient.tests.performance-1'
diff --git a/test/tclient/tests/performance-1.lua b/test/tclient/tests/performance-1.lua
new file mode 100644
index 00000000..65aa62ec
--- /dev/null
+++ b/test/tclient/tests/performance-1.lua
@@ -0,0 +1,67 @@
+local lclient = require 'lclient'
+local util = require 'utility'
+local ws = require 'workspace'
+local files = require 'files'
+local furi = require 'file-uri'
+local fs = require 'bee.filesystem'
+local await = require 'await'
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+
+ client:register('workspace/configuration', function ()
+ return {
+ {
+ ['workspace.library'] = { '${3rd}/Jass/library' }
+ },
+ }
+ end)
+
+ client:initialize()
+
+ ws.awaitReady()
+
+ local text = [[
+local jass = require 'jass.common'
+
+]]
+
+ local clock = os.clock()
+
+ client:awaitRequest('textDocument/didOpen', {
+ textDocument = {
+ uri = furi.encode('abc/performance-1.lua'),
+ languageId = 'lua',
+ version = 0,
+ text = text,
+ }
+ })
+
+ await.sleep(1.0)
+
+ for c in ('jass'):gmatch '.' do
+ text = text .. c
+ client:awaitRequest('textDocument/didChange', {
+ textDocument = {
+ uri = furi.encode('abc/performance-1.lua'),
+ },
+ contentChanges = {
+ {
+ text = text,
+ }
+ }
+ })
+ await.sleep(1.0)
+ end
+
+ local items = client:awaitRequest('textDocument/completion', {
+ textDocument = { uri = furi.encode('abc/performance-1.lua') },
+ position = { line = 2, character = 4 },
+ })
+ local item = client:awaitRequest('completionItem/resolve', items.items[1])
+
+ assert(item.documentation ~= nil)
+
+ print(('Benchmark [performance-1] takes [%.3f] sec.'):format(os.clock() - clock))
+end)