diff options
-rw-r--r-- | test/tclient/init.lua | 2 | ||||
-rw-r--r-- | test/tclient/tests/performance-1.lua | 67 | ||||
-rw-r--r-- | test/tclient/tests/performance-jass-common.lua | 69 |
3 files changed, 70 insertions, 68 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua index d2b86604..e8d3963e 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -5,4 +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' +require 'tclient.tests.performance-jass-common' diff --git a/test/tclient/tests/performance-1.lua b/test/tclient/tests/performance-1.lua deleted file mode 100644 index 65aa62ec..00000000 --- a/test/tclient/tests/performance-1.lua +++ /dev/null @@ -1,67 +0,0 @@ -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) diff --git a/test/tclient/tests/performance-jass-common.lua b/test/tclient/tests/performance-jass-common.lua new file mode 100644 index 00000000..cc982af5 --- /dev/null +++ b/test/tclient/tests/performance-jass-common.lua @@ -0,0 +1,69 @@ +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 clock = os.clock() + + for i = 1, 10 do + local text = [[ +local jass = require 'jass.common' + +]] + + client:awaitRequest('textDocument/didOpen', { + textDocument = { + uri = furi.encode('abc/1.lua'), + languageId = 'lua', + version = i, + text = text, + } + }) + + for c in ('jass'):gmatch '.' do + text = text .. c + client:awaitRequest('textDocument/didChange', { + textDocument = { + uri = furi.encode('abc/1.lua'), + }, + contentChanges = { + { + text = text, + } + } + }) + end + + local results = client:awaitRequest('textDocument/definition', { + textDocument = { uri = furi.encode('abc/1.lua') }, + position = { line = 2, character = 4 }, + }) + + assert(results[1] ~= nil) + + client:awaitRequest('textDocument/didClose', { + textDocument = { uri = furi.encode('abc/1.lua') }, + }) + end + + print(('Benchmark [performance-jass-common] takes [%.3f] sec.'):format(os.clock() - clock)) +end) |