-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading benchmark in README #123
Comments
there is no way to do this with fzy, thats kinda the point if you need to find things i will be fair and show i always knew that this test was misleading but yeah, it is what it is |
Then just add the note c: The A better wording of the note would be: Note The following test uses This way you can skip redoing the benchmarks. On the other hand, being able to reproduce the benchmarks would be nice c: And if you do redo them, then I suggest comparing:
This keeps the benchmarks clear c: |
okay i need to write this down better for documentation but this is the script: local path = require "plenary.path"
local bench = require "plenary.benchmark"
local fzf = require "fzf_lib"
local fzy_lua = require "telescope.algos.fzy"
local fzy_native = require "fzy-lua-native" # romgrk/fzy-lua-native
local files = vim.split(path:new("files"):read(), "\n")
print("Benchmark Setup: 5 warmup and 25 runs each")
bench("fuzzy sorting", {
warmup = 5,
runs = 25,
fun = {
{
"fzf-native pattern: 'f' results: '414451'",
function()
local out = {}
local slab = fzf.allocate_slab()
local p = fzf.parse_pattern("f", 0)
for _, f in ipairs(files) do
local score = fzf.get_score(f, p, slab)
if score > 0 then
table.insert(out, { line = f, score = score })
end
end
fzf.free_pattern(p)
fzf.free_slab(slab)
return #out
end,
},
{
"fzy-native pattern: 'f' results: '414451'",
function()
local out = {}
local needle = "f"
for _, f in ipairs(files) do
if fzy_native.has_match(needle, f) then
local _, score = fzy_native.positions(needle, f)
table.insert(out, { line = f, score = score })
end
end
return #out
end,
},
{
"fzy-lua pattern: 'f' results: '414451'",
function()
local out = {}
local needle = "f"
for _, f in ipairs(files) do
if fzy_lua.has_match(needle, f) then
local _, score = fzy_lua.positions(needle, f)
table.insert(out, { line = f, score = score })
end
end
return #out
end,
},
},
})
bench("fuzzy sorting", {
warmup = 5,
runs = 25,
fun = {
{
"fzf-native pattern: 'main.c' results: '61539'",
function()
local out = {}
local slab = fzf.allocate_slab()
local p = fzf.parse_pattern("main.c", 0)
for _, f in ipairs(files) do
local score = fzf.get_score(f, p, slab)
if score > 0 then
table.insert(out, { line = f, score = score })
end
end
fzf.free_pattern(p)
fzf.free_slab(slab)
return #out
end,
},
{
"fzf-native pattern: 'main.c$' results: '66'",
function()
local out = {}
local slab = fzf.allocate_slab()
local p = fzf.parse_pattern("main.c$", 0)
for _, f in ipairs(files) do
local score = fzf.get_score(f, p, slab)
if score > 0 then
table.insert(out, { line = f, score = score })
end
end
fzf.free_pattern(p)
fzf.free_slab(slab)
return #out
end,
},
{
"fzy-native pattern: 'main.c' results: '61539'",
function()
local out = {}
local needle = "main.c"
for _, f in ipairs(files) do
if fzy_native.has_match(needle, f) then
local _, score = fzy_native.positions(needle, f)
table.insert(out, { line = f, score = score })
end
end
return #out
end,
},
{
"fzy-lua pattern: 'main.c' results: '61539'",
function()
local out = {}
local needle = "main.c"
for _, f in ipairs(files) do
if fzy_lua.has_match(needle, f) then
local _, score = fzy_lua.positions(needle, f)
table.insert(out, { line = f, score = score })
end
end
return #out
end,
},
},
}) and these are the results
|
This benchmark image is misleading:
The patterns used are not the same:
fzf-native
usesmain.c$
fzy-native
usesmain.c
fzf-lua
usesmain.c
Notice the extra
$
at the end infzf-native
. This causesfzf-native
to only find 39 matches compared to the 44215. It is not clear that thefzf-native
search is more specific and thus gives misleading information about the benchmark results.Proposed solution
Add a note like:
Note
Here
fzf-native
is much faster because we can use a narrower match thanks tofzf-native
's syntax:Other solutions that were considered
main.c
for all the queriesmain.c$
for all queries (I couldn't find out iffzy-native
supports regex matches though)The text was updated successfully, but these errors were encountered: