mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 20:18:32 +00:00
fix(tests): unreliable parser_spec #18911
The "first run" has high variability. Looks like the test failures
correlate with 545dc82c1b
, which makes sense because that improves "first run" performance.
So the `1000*` factor of this test could be adjusted to e.g. `300*` or `500*`.
ref https://github.com/neovim/neovim/pull/16945
This commit is contained in:
@@ -169,23 +169,23 @@ void ui_refresh(void)
|
||||
|
||||
it("supports caching queries", function()
|
||||
local long_query = query:rep(100)
|
||||
local first_run = exec_lua ([[
|
||||
local before = vim.loop.hrtime()
|
||||
cquery = vim.treesitter.parse_query("c", ...)
|
||||
local after = vim.loop.hrtime()
|
||||
return after - before
|
||||
]], long_query)
|
||||
local function q(n)
|
||||
return exec_lua ([[
|
||||
local query, n = ...
|
||||
local before = vim.loop.hrtime()
|
||||
for i=1,n,1 do
|
||||
cquery = vim.treesitter.parse_query("c", ...)
|
||||
end
|
||||
local after = vim.loop.hrtime()
|
||||
return after - before
|
||||
]], long_query, n)
|
||||
end
|
||||
|
||||
local subsequent_runs = exec_lua ([[
|
||||
local before = vim.loop.hrtime()
|
||||
for i=1,100,1 do
|
||||
cquery = vim.treesitter.parse_query("c", ...)
|
||||
end
|
||||
local after = vim.loop.hrtime()
|
||||
return after - before
|
||||
]], long_query)
|
||||
local firstrun = q(1)
|
||||
local manyruns = q(100)
|
||||
|
||||
assert.True(1000 * subsequent_runs < first_run)
|
||||
-- First run should be at least 5x slower.
|
||||
assert(500 * manyruns < firstrun, ('firstrun: %d ms, manyruns: %d ms'):format(firstrun / 1000, manyruns / 1000))
|
||||
end)
|
||||
|
||||
it('support query and iter by capture', function()
|
||||
|
Reference in New Issue
Block a user