Skip to content

Commit

Permalink
add lyra to benchmark comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-thomas committed Oct 3, 2022
1 parent a26cd53 commit 2e7eeeb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*"flexsearch-0.6.2", "flexsearch-0.6.3",*/ "minisearch", "flexsearch-0.7.0",
"bm25", "bulksearch", "elasticlunr",
"fuzzysearch", "js-search", "jsii",
"fuse", "lunr", "wade"
"fuse", "lunr", "wade", "lyra"
]);

list.render(lib);
Expand Down
2 changes: 1 addition & 1 deletion bench/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const lib = encode ? [
/*"flexsearch-0.6.2", "flexsearch-0.6.3",*/ "flexsearch-0.7.0-match",
"bm25", "bulksearch-match", "elasticlunr",
"fuzzysearch", "js-search", "jsii",
"minisearch-match", "fuse-match", "lunr", "wade"
"minisearch-match", "fuse-match", "lunr", "wade", "lyra"
];

let promise;
Expand Down
52 changes: 52 additions & 0 deletions bench/test/lyra/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: lyra-0.2.4</h2><hr/>
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
<script type="module">

import { suite } from "../../bench.js";
import { create, search, insert } from "https://unpkg.com/@lyrasearch/[email protected]/dist/esm/src/lyra.js";

let index;

suite["lyra"] = {

init: function(){

index = create({
schema: {
_id: "number",
content: "string"
},
});
},
add: function(data){

for(let i = 0, len = data.length; i < len; i++){

insert(index, {
_id: i,
content: data[i]
});
}
},
query: function(query){

const searchResult = search(index, {
term: query,
properties: ["content"]
});

return searchResult.hits.map(hit => hit._id);
}
};

</script>
</body>
</html>

0 comments on commit 2e7eeeb

Please sign in to comment.