diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2022-06-09 17:07:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 08:07:54 -0700 |
commit | 9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9 (patch) | |
tree | f14aa62fb8cb139db7450339de4caef7ab33f0fb /test/functional/treesitter/parser_spec.lua | |
parent | bf327368d8981b2d974908188a72f2b51b2f8e85 (diff) | |
download | rneovim-9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9.tar.gz rneovim-9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9.tar.bz2 rneovim-9662cd7f48c5dc3b7ab5f5ca3e5b217a03faa6c9.zip |
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 (limited to 'test/functional/treesitter/parser_spec.lua')
-rw-r--r-- | test/functional/treesitter/parser_spec.lua | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index 599c74102c..b074fdbd79 100644 --- 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() |