commit 9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9
parent bf327368d8981b2d974908188a72f2b51b2f8e85
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Thu, 9 Jun 2022 17:07:54 +0200
fix(tests): unreliable parser_spec #18911
The "first run" has high variability. Looks like the test failures
correlate with 545dc82c1b22709c83ec23e9450f245f9ff1babc
, 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
Diffstat:
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
@@ -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 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 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 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()