1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-03 02:42:53 +02:00

update match benchmark

This commit is contained in:
Thomas Wilkerling
2025-03-14 16:35:02 +01:00
parent 33fb61ac4e
commit dc8d04d211
20 changed files with 145 additions and 528 deletions

View File

@@ -223,7 +223,7 @@ function check_test(test){
if(test.init) test.init();
if(test.start) test.start();
if(test.prepare) test.prepare();
test.fn();
//test.fn();
const results = lib.query("gulliver");
if(test.end) test.end();
if(test.complete) test.complete();

View File

@@ -113,7 +113,7 @@
<tbody id="result"></tbody>
</table>
<br>
<sup>1</sup> Measure memory is just supported by Chrome browser so far.<br>
<sup>1</sup> Measure memory is just supported by Chrome browser so far. The amount of memory refers to the allocated memory during query tasks.<br>
<sup>2</sup> The results of these query tests are measured in "terms per second".<br>
<sup>3</sup> The score value is based on median/average factorization, here a score of 100 represents the statistical midfield of all candidates.<br>
<sup>4</sup> The index is a statistic rank having a maximum possible value of 100, this requires a library to be the best in each test category (regardless how much better).<br><br>

View File

@@ -8,17 +8,27 @@ const lib = encode ? [
"flexsearch-match", "flexsearch-memory", "flexsearch-score",
"flexsearch-speed"
]:[
/*"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", "lyra"
/*"flexsearch-0.6.2", "flexsearch-0.6.3",*/
//"flexsearch-0.7.0-match",
"flexsearch-0.8.0-match",
"bm25",
"elasticlunr",
"fuzzysearch",
"js-search",
"jsii",
"fuse-match",
"lunr-match",
"wade",
"minisearch-match",
"orama", // was called "lyra"
"ufuzzy-match"
];
let promise;
window.onmessage = function(event){
if(event.origin === location.protocol + "//" + location.hostname + ":" + location.port){
if(event.origin === location.origin){
const results = JSON.parse(event.data);
//console.log(results);
@@ -38,11 +48,10 @@ const root_head = document.getElementsByTagName("thead")[0].firstElementChild,
const tpl_tr = document.createElement("tr");
for(let i = 0; i < lib.length + 1; i++){ // amount of libs + 1 for first row
tpl_tr.appendChild(tpl_td.cloneNode(true));
}
for(let i = 0; i < 12; i++){ // amount of tests + 1 for first row
for(let i = 0; i < 13; i++){ // amount of tests + 1 for first row
const tr = tpl_tr.cloneNode(true);
tr.id = "test-" + (i + 1);
@@ -55,17 +64,29 @@ const headers = root_head.getElementsByTagName("td");
// -----------------------------------------------------------
// strict search, original text: without breach of modesty
await do_test("test-1", "without breach of modesty", [2684]);
// skipped terms, original text: went down softly into the stream
await do_test("test-2", "went softly stream", [2432]);
// swapped terms, original text: is the ambition of princes
await do_test("test-3", "princes of the ambition", [2259, 396]);
// word break insensitive, original text: five thousand leagues
await do_test("test-4", "five-thousand leagues", [7]);
await do_test("test-5", "raise up soft", [2069]);
await do_test("test-6", "disgust the bigness", [946]);
// forward partial match, original text: the bigness disgusted
await do_test("test-5", "disgust the bignes", [946]);
// stemmer, original text: softly raising up
await do_test("test-6", "raise up soft", [2069]);
// simple transformation, original text: bigness of a splacknuck
await do_test("test-7", "bignes of splaknuk", [781]);
// balance transformation, original text: mathematical and musical instruments
await do_test("test-8", "matematikal musikal instruments", [1480]);
await do_test("test-9", "composition of minerals gums juices vegetables", [1676, 2337]);
await do_test("test-10", "general camberlayhn", [520]);
await do_test("test-11", "the end defeat", [2209]);
// relevance on missing term, original text:
await do_test("test-9", "minerals gums juices vegetables", [2337]); // 1676 does not include "vegetables"
// advanced transformation, original text: Chamberlain
await do_test("test-10", "camperlayhn", [1903,520,535]);
// original text: Houyhnhnms
await do_test("test-11", "hoymns", [2215,2427,2440,2464,2477,2489,2500,2691,2715,2717,2353,2392,2453,2486,2513,2541,2548,23,2177,2204,2455,2680,2020,2484,2528,2640,2211,2447,2478,2514,2709,24,2549,2556,2574,2205,2498,2466,2542,2579,2607,7,2212,2363,2474,2573,2606,21,2674,2443,2551,2660,2684]);
// reverse partial match, original text: fastened my handkerchief
await do_test("test-12", "fast chief", [1275]);
// ---------------------------------------
@@ -77,7 +98,7 @@ async function do_test(id, query, ref){
for(let i = 0, current; i < lib.length; i++){
current = lib[i].replace("-0.7.0", "").replace("-match", "");
current = lib[i]/*.replace("-0.7.0", "")*/.replace("-match", "");
headers[i + 1].firstChild.nodeValue = current;
const node = nodes[i + 1];
@@ -86,7 +107,6 @@ async function do_test(id, query, ref){
node.firstChild.nodeValue = "run ...";
let results = await new Promise(function(resolve){
promise = resolve;
iframe.src = "test/" + lib[i] + "/?query=" + decodeURI(query) + (encode ? "&encode=true" : "") + "#match";
});
@@ -125,14 +145,12 @@ async function do_test(id, query, ref){
style.color = "#fff";
style.backgroundColor = "";
if((results[a] === current) ||
(results[a] === ("" + current))){
if(style.backgroundColor !== "orange"){
if(((ref.includes(results[a]) /*results[a] === current*/) ||
(ref.includes(parseInt(results[a], 10)) /*results[a] === ("" + current)*/)) && results.length >= ref.length){
//if(style.backgroundColor !== "orange"){
style.backgroundColor = "#0a0";
}
// }
break;
}
else if(!results.length ||
((results.indexOf(current) === -1) &&
@@ -144,6 +162,7 @@ async function do_test(id, query, ref){
else{
style.backgroundColor = "orange";
break;
}
}
}

View File

@@ -1,51 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: bulksearch-0.1.3</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 src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["bulksearch"] = {
init: function(){
lib = new BulkSearch({
type: "short",
encode: 'extra',
multi: true
});
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
update: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.update(i, data[i]);
}
},
query: function(query){
return lib.search(query, { suggest: true });
}
};
</script>
</body>
</html>

View File

@@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: bulksearch-0.1.3</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 src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.light.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["bulksearch"] = {
init: function(){
lib = new BulkSearch({
type: "short",
encode: "icase",
multi: false,
async: false,
cache: false,
worker: false
});
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
update: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.update(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,51 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-0.7.0</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 Index from "../../../src/index.js";
//import Document from "../../../src/document.js";
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-0.7.0-match"] = {
init: function(){
lib = new Index({ context: { depth: 2 } });
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query, 10, { suggest: true });
},
update: function(id){
for(let i = 0, len = data.length; i < len; i++){
lib.update(i, data[i]);
}
},
remove: function(id){
lib.remove(id);
}
};
</script>
</body>
</html>

View File

@@ -10,9 +10,8 @@
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
<script type="module">
import Index from "../../../src/index.js";
//import Document from "../../../src/document.js";
import { encode } from "../../../src/lang/latin/advanced.js";
import Index from "https://rawcdn.githack.com/nextapps-de/flexsearch/0.7.31/src/index.js";
import { encode } from "https://rawcdn.githack.com/nextapps-de/flexsearch/0.7.31/src/lang/latin/advanced.js";
import { suite } from "../../bench.js";
let lib;
@@ -20,35 +19,19 @@
suite["flexsearch-0.7.0-match"] = {
init: function(){
lib = new Index({
encode: encode,
tokenize: "reverse",
resolution: 20
});
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query, 10, { suggest: true });
},
update: function(id){
for(let i = 0, len = data.length; i < len; i++){
lib.update(i, data[i]);
}
},
remove: function(id){
lib.remove(id);
return lib.search(query, { suggest: true });
}
};

View File

@@ -10,10 +10,10 @@
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<p style="color: #f00">This test is using query cache and is outside the competition! It is just there for completion.</p>
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/flexsearch.light.min.js"></script>
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/flexsearch.light.min.js"></script>
<script type="module">
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/module-min/lang/en.js";
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/module-min/lang/en.js";
import { suite } from "../../bench.js";
let lib;

View File

@@ -9,10 +9,10 @@
<h2>Benchmark: flexsearch-0.8.0-soundex</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 src="https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/flexsearch.compact.min.js"></script>
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/flexsearch.compact.min.js"></script>
<script type="module">
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/module-min/lang/en.js";
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/module-min/lang/en.js";
import { suite } from "../../bench.js";
let lib;

View File

@@ -9,10 +9,10 @@
<h2>Benchmark: flexsearch-0.8.0</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 src="https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/flexsearch.light.min.js"></script>
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/flexsearch.light.min.js"></script>
<script type="module">
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/v0.8-preview/dist/module-min/lang/en.js";
import EnglishPreset from "https://rawcdn.githack.com/nextapps-de/flexsearch/aff94f2b1d830e21463b237070f7e6f7eb556b82/dist/module-min/lang/en.js";
import { suite } from "../../bench.js";
let lib;

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-balance"] = {
init: function(){
lib = new FlexSearch("balance");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.light.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-default"] = {
init: function(){
lib = new FlexSearch();
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,52 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-ctx"] = {
init: function(){
lib = new FlexSearch({
//encode: "icase",
tokenize: "strict",
threshold: 8,
resolution: 9,
depth: 1,
doc: {
id: "id",
field: "content"
}
});
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add({
id: i,
content: data[i]
});
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.light.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-fast"] = {
init: function(){
lib = new FlexSearch("fast");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-match"] = {
init: function(){
lib = new FlexSearch("match");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-memory"] = {
init: function(){
lib = new FlexSearch("memory");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-score"] = {
init: function(){
lib = new FlexSearch("score");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
</head>
<body>
<h2>Benchmark: flexsearch-ctx-0.7.0</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 src="../../dist/flexsearch.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["flexsearch-speed"] = {
init: function(){
lib = new FlexSearch("speed");
},
add: function(data){
for(let i = 0, len = data.length; i < len; i++){
lib.add(i, data[i]);
}
},
query: function(query){
return lib.search(query);
}
};
</script>
</body>
</html>

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height">
<title>Benchmark: lunr-2.3.9</title>
</head>
<body>
<h2>Benchmark: lunr-2.3.9</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 src="https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let lib;
suite["lunr-match"] = {
init: function(){},
add: function(data){
lib = lunr(function(){
this.ref("id");
this.field("content");
for(let i = 0; i < data.length; i++){
this.add({
id: i,
content: data[i]
});
}
});
},
query: function(query){
return lib.search(query, { wildcard: lunr.Query.wildcard.LEADING });
// const result = lib.query(function(q) {
// q.term(query, { wildcard: lunr.Query.wildcard.LEADING })
// });
// for(let i = 0; i < result.length; i++){
// result[i] = parseInt(result[i].ref, 10);
// }
// return result;
}
};
</script>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height">
<title>Benchmark: ufuzzy-1.0.18</title>
</head>
<body>
<h2>Benchmark: ufuzzy-1.0.18</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 src="https://rawcdn.githack.com/leeoniya/uFuzzy/main/dist/uFuzzy.iife.min.js"></script>
<script type="module">
import { suite } from "../../bench.js";
let uf, content;
suite["ufuzzy"] = {
init: function(){
let opts = {
alpha: "a-z",
intraMode: 9,
intraIns: 9,
intraSub: 9,
intraTrn: 9,
intraDel: 9
};
uf = new window.uFuzzy(opts);
},
add: function(data){
content = data;
},
query: function(query){
return uf.search(content, query)[0];
}
};
</script>
</body>
</html>