feat(benchmark): add util to benchmark functions#228
feat(benchmark): add util to benchmark functions#228Conni2461 merged 5 commits intonvim-lua:masterfrom kkharji:master
Conversation
|
|
||
| if res.bufnr then | ||
| vim.api.nvim_buf_set_option(res.bufnr, "filetype", "PlenaryTestPopup") | ||
| end |
There was a problem hiding this comment.
This I had for awhile because I want to attach stuff to the test buffer. So maybe just act as if it isn't there :D
|
Update bench("Predicting Y", {
runs = 10,
fun = {
base = function()
vim.wait(200, function() end)
end,
ench = function()
vim.wait(100, function() end)
end,
},
})
|
|
I can't push (no idea why) New interface after my changes bench {
warmup = 3,
runs = 50,
fun = {
{
"uv",
function()
local fd = assert(vim.loop.fs_open("README.md", "r", 438))
local stat = assert(vim.loop.fs_fstat(fd))
local data = assert(vim.loop.fs_read(fd, stat.size, 0))
assert(vim.loop.fs_close(fd))
return data
end,
},
{
"io",
function()
local fp = assert(io.open "README.md", "r")
local contents = fp:read "*all"
fp:close()
return contents
end,
},
},
} |
|
Great work conni, thank you. I'm about to reach home, but don't you agree you should have name of the benchmark as first param to keep consistent with busted style, like it and describe |
|
I removed it because i didnt know what to do with it. I mostly stole the format from hyperfine because its a good format. For now i just needed benchmarks between fzf-native, fzy-native and fzf-lua for the telescope wiki. If you wanna add it back. Thats fine too. Right now i am more concerned with the wiki changes which i wanna get done today |
co-authored-by: Conni2461 <Simon-Hauser@outlook.de>
|
new output Interface bench("IO Vs LIBUV", {
warmup = 3,
runs = 80,
fun = {
{
"uv",
function()
local fd = assert(vim.loop.fs_open("README.md", "r", 438))
local stat = assert(vim.loop.fs_fstat(fd))
local data = assert(vim.loop.fs_read(fd, stat.size, 0))
assert(vim.loop.fs_close(fd))
return data
end,
},
{
"io",
function()
local fp = assert(io.open "README.md", "r")
local contents = fp:read "*all"
fp:close()
return contents
end,
},
},
})
|
|
@Conni2461 if it looks good to you, I think we should merge, otherwise tag me |
|
Can we also get some simple tests for the stat module. After that i would be fine with merging. Thanks :) |
you mean stat.lua. 🤔 not sure how I might do that or if it's going to be modified anytime in the future since it's pretty static and standard |
|
Yeah Thanks :) |

Trying to add a way in which we can tests the performance and improve it. I'd like to have this be part of busted run test output somehow. maybe through a global variable 'bench_run', 'bench_compare'
example:
output
not sure how to do compare yet