mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-24 20:41:28 +02:00
update libs to latest
This commit is contained in:
44
bench.js
44
bench.js
@@ -167,6 +167,7 @@ queue.push({
|
||||
count: 25
|
||||
});
|
||||
|
||||
/*
|
||||
queue.push({
|
||||
name: "query-dupes",
|
||||
init: null,
|
||||
@@ -181,6 +182,7 @@ queue.push({
|
||||
complete: null,
|
||||
count: 7
|
||||
});
|
||||
*/
|
||||
|
||||
queue.push({
|
||||
name: "not-found",
|
||||
@@ -256,15 +258,13 @@ async function perform(){
|
||||
let cycle = 1, max_cycle = test.cycle, inner_count = test.count;
|
||||
let elapsed = 0, memory = 0;
|
||||
let loops = 0, now = 0;
|
||||
let start, mem_start, mem;
|
||||
|
||||
if(status){
|
||||
|
||||
if(test.init) test.init();
|
||||
const end = perf.now() + duration;
|
||||
let start, mem_start, mem;
|
||||
|
||||
while(now < end){
|
||||
while(elapsed < duration){
|
||||
|
||||
if(test.start) test.start(loops);
|
||||
|
||||
@@ -272,11 +272,10 @@ async function perform(){
|
||||
mem_start = perf.memory.usedJSHeapSize;
|
||||
start = perf.now();
|
||||
for(let i = 0; i < cycle; i++) test.fn();
|
||||
now = perf.now();
|
||||
elapsed += perf.now() - start;
|
||||
mem = perf.memory.usedJSHeapSize - mem_start;
|
||||
// -- END -------------------
|
||||
|
||||
elapsed += (now - start);
|
||||
if(mem > 0) memory += mem;
|
||||
if(test.end) test.end(loops);
|
||||
loops += cycle;
|
||||
@@ -288,41 +287,6 @@ async function perform(){
|
||||
if(max_cycle && (cycle > max_cycle)){
|
||||
cycle = max_cycle;
|
||||
}
|
||||
|
||||
// mem_start = perf.memory.usedJSHeapSize;
|
||||
// start = performance.now();
|
||||
// for(let i = 0; i < cycle; i++) test.fn();
|
||||
// elapsed += (performance.now() - start);
|
||||
// mem = perf.memory.usedJSHeapSize - mem_start;
|
||||
// loops += cycle;
|
||||
// if(mem > 0) memory += mem;
|
||||
// if(test.end) test.end(loops);
|
||||
|
||||
// console.log(test.name);
|
||||
// console.log("duration", duration);
|
||||
// console.log("elapsed", elapsed);
|
||||
// console.log("cycle", cycle);
|
||||
// console.log("loops", loops);
|
||||
|
||||
//if(cycle ===1) cycle = cycle * (duration / (elapsed || 1)) | 0;
|
||||
|
||||
// console.log("loops", loops, "elapsed", elapsed, "duration", duration, "cycle", (loops / (elapsed || 1) * (duration - elapsed)) | 0);
|
||||
//
|
||||
// //cycle = (loops / (elapsed || 1) * (duration - elapsed) * 1.2) | 0;
|
||||
// //cycle *= loops / (elapsed || 1) * (duration - elapsed) / 2 | 0;
|
||||
// cycle *= duration / (elapsed || 1);
|
||||
// if(cycle < 1){
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// //cycle = loops / (elapsed || 1) * (duration - elapsed);
|
||||
//
|
||||
// if(max_cycle && (cycle > max_cycle)){
|
||||
// cycle = max_cycle;
|
||||
// }
|
||||
//
|
||||
// //console.log(elapsed, duration, cycle)
|
||||
// //await new Promise(resolve => setTimeout(resolve, 50));
|
||||
}
|
||||
|
||||
if(test.complete) test.complete();
|
||||
|
32
index.html
32
index.html
@@ -1,5 +1,6 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Benchmark of Web Templating Engines (Non-Keyed)</title>
|
||||
<style>
|
||||
body{
|
||||
@@ -38,6 +39,7 @@
|
||||
<input type="button" id="start" click="start" value="Start">
|
||||
</td>
|
||||
<td> </td>
|
||||
<!--
|
||||
<td>
|
||||
Mode:
|
||||
<select id="mode" change="mode">
|
||||
@@ -46,6 +48,15 @@
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
-->
|
||||
<td>
|
||||
Results:
|
||||
<select id="calc">
|
||||
<option value="median">Median</option>
|
||||
<option value="average">Average</option>
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
Duration:
|
||||
<select id="duration">
|
||||
@@ -83,25 +94,28 @@
|
||||
<tr>
|
||||
<th>Library</th>
|
||||
<th hidden>Size</th>
|
||||
<th>Memory *</th>
|
||||
<th>Memory <sup>1</sup></th>
|
||||
<!--
|
||||
<th>Add</th>
|
||||
<th>Update</th>
|
||||
<th>Remove</th>
|
||||
-->
|
||||
<th>Query (Single Term)</th>
|
||||
<th>Query (Multi Term)</th>
|
||||
<th>Query (Long)</th>
|
||||
<th>Query (Dupes)</th>
|
||||
<th>Query (Not Found)</th>
|
||||
<th>Index</th>
|
||||
<th>Score</th>
|
||||
<th>Query: Single <sup>2</sup></th>
|
||||
<th>Query: Multi <sup>2</sup></th>
|
||||
<th>Query: Large <sup>2</sup></th>
|
||||
<!--<th>Query (Dupes)</th>-->
|
||||
<th>Query: Not Found <sup>2</sup></th>
|
||||
<th>Score <sup>3</sup></th>
|
||||
<th>Index <sup>4</sup></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result"></tbody>
|
||||
</table>
|
||||
<br>
|
||||
* To measure memory you have to run in Chrome browser.<br><br>
|
||||
<sup>1</sup> Measure memory is just supported by Chrome browser so far.<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>
|
||||
<b>Single Tests:</b>
|
||||
<ul id="lib"></ul>
|
||||
<iframe id="iframe" hidden></iframe>
|
||||
|
84
index.js
84
index.js
@@ -21,11 +21,19 @@
|
||||
"flexsearch-match", "flexsearch-memory", "flexsearch-score",
|
||||
"flexsearch-speed"
|
||||
]:[
|
||||
//"flexsearch-0.6.2", "flexsearch-0.6.3",
|
||||
"flexsearch-0.7.0", "flexsearch-0.8.0",
|
||||
"bm25", "bulksearch", "elasticlunr",
|
||||
"fuzzysearch", "js-search", "jsii",
|
||||
"fuse", "lunr", "wade", "lyra", "minisearch"
|
||||
//"flexsearch-0.6.2", "flexsearch-0.6.3", /*"bulksearch",*/
|
||||
"flexsearch-0.7.0",
|
||||
"flexsearch-0.8.0",
|
||||
"bm25",
|
||||
"elasticlunr",
|
||||
"fuzzysearch",
|
||||
"js-search",
|
||||
"jsii",
|
||||
"fuse",
|
||||
"lunr",
|
||||
"wade",
|
||||
"minisearch",
|
||||
"orama" // was lyra before
|
||||
]);
|
||||
|
||||
list.render(lib);
|
||||
@@ -65,36 +73,11 @@
|
||||
]:[
|
||||
"size", "memory",
|
||||
//"add",
|
||||
"query-single", "query-multi", "query-long", "query-dupes", "not-found"
|
||||
"query-single", "query-multi", "query-long", /*"query-dupes",*/ "not-found"
|
||||
];
|
||||
|
||||
const current = new Array(lib.length);
|
||||
|
||||
// let size = {
|
||||
//
|
||||
// "bm25": 1,
|
||||
// "bulksearch": 1,
|
||||
// "elasticlunr": 1,
|
||||
// "fuse": 1,
|
||||
// "fuzzysearch": 1,
|
||||
// "js-search": 1,
|
||||
// "jsii": 1,
|
||||
// "lunr": 1,
|
||||
// "wade": 1,
|
||||
//
|
||||
// "flexsearch-0.6.2": 1,
|
||||
// "flexsearch-0.6.3": 1,
|
||||
// "flexsearch-0.7.0": 1,
|
||||
//
|
||||
// "flexsearch-balance": 1,
|
||||
// "flexsearch-default": 1,
|
||||
// "flexsearch-fast": 1,
|
||||
// "flexsearch-match": 1,
|
||||
// "flexsearch-memory": 1,
|
||||
// "flexsearch-score": 1,
|
||||
// "flexsearch-speed": 1
|
||||
// };
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
current[x] = {
|
||||
@@ -142,21 +125,18 @@
|
||||
if(current[x][test[y]] && (current[x][test[y]] !== "-failed-")){
|
||||
|
||||
if(current[x][test[y]]){
|
||||
|
||||
val[y].push(current[x][test[y]]);
|
||||
}
|
||||
|
||||
// lower is better
|
||||
if((test[y] === "size") || (test[y] === "memory")){
|
||||
|
||||
if((current[x][test[y]] < max[y]) || !max[y]){
|
||||
|
||||
max[y] = current[x][test[y]];
|
||||
}
|
||||
}
|
||||
// higher is better
|
||||
else{
|
||||
|
||||
if(current[x][test[y]] > max[y]){
|
||||
|
||||
max[y] = current[x][test[y]];
|
||||
}
|
||||
}
|
||||
@@ -168,6 +148,7 @@
|
||||
let index = new Array(lib.length);
|
||||
let length = new Array(lib.length);
|
||||
let max_score = 0, max_index = 0;
|
||||
let calc = document.getElementById("calc").value;
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
@@ -181,15 +162,16 @@
|
||||
|
||||
length[x]++;
|
||||
|
||||
// reduce importance of test "size" and "memory"
|
||||
if((test[y] === "size") || (test[y] === "memory")){
|
||||
|
||||
score[x] += Math.sqrt(median(val[y]) / current[x][test[y]]);
|
||||
// median on timing results will cut out garbage collector and will lead into false results
|
||||
score[x] += Math.sqrt((calc === "median" ? median : average)(val[y]) / current[x][test[y]]);
|
||||
index[x] += Math.sqrt(max[y] / current[x][test[y]]);
|
||||
current[x]["color_" + test[y]] = color(Math.sqrt(max[y]), Math.sqrt(current[x][test[y]]));
|
||||
}
|
||||
else{
|
||||
|
||||
score[x] += current[x][test[y]] / median(val[y]);
|
||||
// median on timing results will cut out garbage collector and will lead into false results
|
||||
score[x] += current[x][test[y]] / (calc === "median" ? median : average)(val[y]);
|
||||
index[x] += current[x][test[y]] / max[y];
|
||||
current[x]["color_" + test[y]] = color(current[x][test[y]], max[y]);
|
||||
}
|
||||
@@ -200,8 +182,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
current[x]["score"] = (score[x] / length[x] * 1000 + 0.5) | 0;
|
||||
current[x]["index"] = (index[x] / length[x] * 1000 + 0.5) | 0;
|
||||
current[x]["score"] = (score[x] / length[x] * 100 + 0.5) | 0;
|
||||
current[x]["index"] = (index[x] / length[x] * 100 + 0.5) | 0;
|
||||
if(max_score < current[x]["score"]) max_score = current[x]["score"];
|
||||
if(max_index < current[x]["index"]) max_index = current[x]["index"];
|
||||
}
|
||||
@@ -346,4 +328,22 @@
|
||||
);
|
||||
}
|
||||
|
||||
function sum(arr){
|
||||
|
||||
const length = arr.length;
|
||||
let sum = 0;
|
||||
|
||||
for(let i = 0; i < length; i++){
|
||||
|
||||
sum += arr[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
function average(arr){
|
||||
|
||||
return sum(arr) / arr.length;
|
||||
}
|
||||
|
||||
}());
|
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: flexsearch-0.7.0</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: flexsearch-0.8.0</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.8.0</h2><hr/>
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: fuse-7.1.0</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: fuse-3.3.0</h2><hr/>
|
||||
<h2>Benchmark: fuse-7.1.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://cdn.jsdelivr.net/gh/krisk/Fuse@3.3.0/dist/fuse.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@v7.1.0/dist/fuse.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: js-search-2.0.1</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: js-search-1.4.2</h2><hr/>
|
||||
<h2>Benchmark: js-search-2.0.1</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/js-search@1.4.2/dist/umd/js-search.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-search@2.0.1/dist/umd/js-search.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: lunr-2.3.9</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: lunr-2.3.5</h2><hr/>
|
||||
<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.5/lunr.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: lyra-0.2.4</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: lyra-0.2.4</h2><hr/>
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: minisearch-7.1.2</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: minisearch</h2><hr/>
|
||||
<h2>Benchmark: minisearch-7.1.2</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/minisearch@3.0.2/dist/umd/index.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/minisearch@7.1.2/dist/umd/index.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
52
test/orama/index.html
Normal file
52
test/orama/index.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark: orama-3.1.1</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: orama-3.1.1</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://cdn.jsdelivr.net/npm/@orama/orama@v3.1.1/+esm";
|
||||
|
||||
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>
|
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<title>Benchmark: wade-0.3.3</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: wade-0.3.3</h2><hr/>
|
||||
|
@@ -5,8 +5,8 @@
|
||||
<td style="background-color:{{data['color_query-single']}}">{{data['query-single']}}</td>
|
||||
<td style="background-color:{{data['color_query-multi']}}">{{data['query-multi']}}</td>
|
||||
<td style="background-color:{{data['color_query-long']}}">{{data['query-long']}}</td>
|
||||
<td style="background-color:{{data['color_query-dupes']}}">{{data['query-dupes']}}</td>
|
||||
<!--<td style="background-color:{{data['color_query-dupes']}}">{{data['query-dupes']}}</td>-->
|
||||
<td style="background-color:{{data['color_not-found']}}">{{data['not-found']}}</td>
|
||||
<td style="background-color:{{data.color_index}}"><b>{{data.index}}</b></td>
|
||||
<td style="background-color:{{data.color_score}}"><b>{{data.score}}</b></td>
|
||||
<td style="background-color:{{data.color_index}}"><b>{{data.index}}</b></td>
|
||||
</tr>
|
||||
|
12
tpl/row.js
12
tpl/row.js
@@ -55,7 +55,7 @@ Mikado.register({
|
||||
"data['query-long']"
|
||||
]
|
||||
},
|
||||
{
|
||||
/*{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-dupes']"
|
||||
@@ -63,7 +63,7 @@ Mikado.register({
|
||||
"x": [
|
||||
"data['query-dupes']"
|
||||
]
|
||||
},
|
||||
},*/
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
@@ -78,11 +78,11 @@ Mikado.register({
|
||||
"i": {
|
||||
"t": "b",
|
||||
"x": [
|
||||
"data.index"
|
||||
"data.score"
|
||||
]
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_index"
|
||||
"'background-color:' + data.color_score"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -90,11 +90,11 @@ Mikado.register({
|
||||
"i": {
|
||||
"t": "b",
|
||||
"x": [
|
||||
"data.score"
|
||||
"data.index"
|
||||
]
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_score"
|
||||
"'background-color:' + data.color_index"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user