Skip to content

Commit

Permalink
add fzf-for-js bench
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Oct 16, 2022
1 parent 749e501 commit 598acc2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,19 @@ https://bestofjs.org/projects?tags=search
<td>11.3MB</td>
<td>30ms</td>
</tr>
<tr>
<td>
<a href="https://github.com/ajitid/fzf-for-js">fzf-for-js</a>
(<a href="https://leeoniya.github.io/uFuzzy/demos/compare.html?libs=fzf-for-js&search=super%20ma">try</a>)
</td>
<td>★ 538</td>
<td>15.4KB</td>
<td>75ms</td>
<td>6700ms</td>
<td>353MB</td>
<td>190MB</td>
<td>160ms</td>
</tr>
<tr>
<td>
<a href="https://github.com/rmm5t/liquidmetal">LiquidMetal</a>
Expand Down
45 changes: 45 additions & 0 deletions demos/compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,51 @@
search: null,
toStr: null,
},
{
name: 'fzf-for-js',
script: './lib/fzf.iife.min.js',
fulltext: false,
repo: 'https://github.com/ajitid/fzf-for-js',
opts: {},
setup: (haystack, opts) => {
const fzf = new Fzf.Fzf(haystack, {
casing: 'case-insensitive',
normalize: false,
});

let toStr;

return {
search: needle => {
let matches = fzf.find(needle);

if (matches.length <= 1e3) {
toStr = m => {
let item = m.item;
let pos = m.positions;
let s = '';

for (let i = 0; i < item.length; i++) {
if (pos.has(i))
s += '<mark>' + item[i] + '</mark>'
else
s += item[i];
}

return s;
};
}
else
toStr = m => m.item;

return matches;
},
toStr: m => toStr(m),
};
},
search: null,
toStr: null,
},
// TODO:
// https://github.com/nol13/fuzzball.js
];
Expand Down
28 changes: 28 additions & 0 deletions demos/lib/fzf.iife.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 598acc2

Please sign in to comment.