mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-08-30 17:20:17 +02:00
remove bench from master branch
This commit is contained in:
327
bench/bench.js
327
bench/bench.js
@@ -1,327 +0,0 @@
|
||||
import { text_data } from "../demo/data/gulliver.js";
|
||||
|
||||
export let suite = {};
|
||||
export const test = {};
|
||||
const result = document.getElementById("result").appendChild(document.createTextNode("running..."));
|
||||
const match = window.location.hash.indexOf("match") !== -1;
|
||||
export const queue = [];
|
||||
let lib;
|
||||
|
||||
const params = (function(){
|
||||
|
||||
const obj = {};
|
||||
const pairs = window.location.search.substring(1).split('&');
|
||||
|
||||
for(let i = 0, split; i < pairs.length; i++){
|
||||
split = pairs[i].split('=');
|
||||
obj[split[0]] = split[1];
|
||||
}
|
||||
|
||||
return obj;
|
||||
}());
|
||||
|
||||
let runs;
|
||||
let duration;
|
||||
|
||||
if(params["duration"] && (params["duration"].indexOf("run-") !== -1)){
|
||||
|
||||
duration = 86400000;
|
||||
runs = parseInt(params["duration"].replace("run-", ""), 10);
|
||||
}
|
||||
else{
|
||||
|
||||
duration = parseFloat(params["duration"] || "5") * 1000;
|
||||
}
|
||||
|
||||
// if(match){
|
||||
//
|
||||
// text_data.push('zero one two three four five six seven eight nine ten');
|
||||
// text_data.push('four two zero one three ten five seven eight six nine');
|
||||
// text_data.push('zero one two three four five six seven eight nine ten');
|
||||
// }
|
||||
|
||||
// queue.push({
|
||||
// name: "add",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: null,
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// count: text_data.length
|
||||
// });
|
||||
//
|
||||
// queue.push({
|
||||
// name: "update",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// count: text_data.length
|
||||
// });
|
||||
//
|
||||
// let index;
|
||||
//
|
||||
// queue.push({
|
||||
// name: "remove",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// index = 0;
|
||||
// },
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.remove(index++);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// cycle: text_data.length,
|
||||
// count: 1
|
||||
// });
|
||||
|
||||
queue.push({
|
||||
name: "query-single",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("gulliver");
|
||||
lib.query("great");
|
||||
lib.query("country");
|
||||
lib.query("time");
|
||||
lib.query("people");
|
||||
lib.query("little");
|
||||
lib.query("master");
|
||||
lib.query("took");
|
||||
lib.query("feet");
|
||||
lib.query("houyhnhnms");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 10
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "query-multi",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("italians homunceletino");
|
||||
lib.query("theodorus vangrult");
|
||||
lib.query("virtuous houyhnhnms");
|
||||
lib.query("creature discovered");
|
||||
lib.query("lord high chancellor");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 5
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "query-long",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("there were six spanish pieces of four pistoles");
|
||||
lib.query("glumdalclitch and i attended the king and queen in a progress");
|
||||
lib.query("only in this island of luggnagg the appetite for living was not so eager");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 3
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "query-dupes",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("gulliver gulliver gulliver");
|
||||
lib.query("italians homunceletino italians homunceletino");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 2
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "not-found",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("undefined");
|
||||
lib.query("undefineda undefinedb undefinedc");
|
||||
lib.query("lord high undefined");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 3
|
||||
});
|
||||
|
||||
// #####################################################################################
|
||||
// #####################################################################################
|
||||
|
||||
window.onload = function(){
|
||||
|
||||
if(queue.length){
|
||||
|
||||
lib = suite[Object.keys(suite)[0]];
|
||||
lib.init();
|
||||
lib.add(text_data);
|
||||
|
||||
setTimeout(match ? perform_match : perform, 200);
|
||||
}
|
||||
};
|
||||
|
||||
// #####################################################################################
|
||||
// #####################################################################################
|
||||
|
||||
function check_test(test){
|
||||
|
||||
if(test.init) test.init();
|
||||
if(test.start) test.start();
|
||||
if(test.prepare) test.prepare();
|
||||
test.fn();
|
||||
const results = lib.query("gulliver");
|
||||
if(test.end) test.end();
|
||||
if(test.complete) test.complete();
|
||||
|
||||
//console.log(results);
|
||||
|
||||
return results.length >= 6;
|
||||
}
|
||||
|
||||
function msg(message, a){
|
||||
|
||||
a ? console.error(message, a) : console.error(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// #####################################################################################
|
||||
// #####################################################################################
|
||||
|
||||
let str_results = "";
|
||||
const perf = window.performance;
|
||||
perf.memory || (perf.memory = { usedJSHeapSize: 0 });
|
||||
|
||||
let current = 0;
|
||||
|
||||
function perform(){
|
||||
|
||||
const test = queue[current];
|
||||
|
||||
if(current === 0) check_test(test) || msg("Main test failed!");
|
||||
|
||||
let elapsed = 0, memory = 0;
|
||||
let status = true;
|
||||
let loops = 0, cycle = 1, now = 0, max_cycle = test.cycle, inner_count = test.count;
|
||||
|
||||
if(status){
|
||||
|
||||
if(test.init) test.init();
|
||||
|
||||
const end = perf.now() + duration;
|
||||
|
||||
for(let start, mem_start, mem; now < end;){
|
||||
|
||||
if(test.start) test.start(loops);
|
||||
|
||||
mem_start = perf.memory.usedJSHeapSize;
|
||||
start = perf.now();
|
||||
for(let i = 0; i < cycle; i++) test.fn();
|
||||
now = perf.now();
|
||||
mem = perf.memory.usedJSHeapSize - mem_start;
|
||||
elapsed += (now - 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);
|
||||
|
||||
cycle *= duration / (elapsed || 1);
|
||||
//cycle = loops / (elapsed || 1) * (duration - elapsed);
|
||||
|
||||
// if(cycle < 0){
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
|
||||
if(max_cycle && (cycle > max_cycle)){
|
||||
|
||||
cycle = max_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
if(test.complete) test.complete();
|
||||
}
|
||||
|
||||
loops *= inner_count || 1;
|
||||
current++;
|
||||
|
||||
if(window === window.top){
|
||||
|
||||
result.nodeValue = (str_results += (status ? test.name.padEnd(12) + String(Math.ceil(1000 / elapsed * loops)).padStart(8) + " op/s, Memory:\t" + (memory ? Math.ceil(memory / loops) : "-") : "- failed -") + "\n") + (current < queue.length ? "running..." : "");
|
||||
}
|
||||
else{
|
||||
|
||||
window.top.postMessage(test.name + "," + (status ? Math.ceil(1000 / elapsed * loops) : 0) + "," + (status ? Math.ceil(memory / loops) : 0), location.protocol + "//" + location.hostname); //"https://nextapps-de.github.io" "https://raw.githack.com"
|
||||
}
|
||||
|
||||
if(current < queue.length){
|
||||
|
||||
setTimeout(perform, 200);
|
||||
}
|
||||
else{
|
||||
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function perform_match(){
|
||||
|
||||
const test = queue[current];
|
||||
const query = decodeURI(params["query"]);
|
||||
|
||||
check_test(test) || msg("Main test failed!");
|
||||
|
||||
const res = lib.query(query);
|
||||
|
||||
if(window === window.top){
|
||||
|
||||
result.nodeValue = JSON.stringify(res);
|
||||
}
|
||||
else{
|
||||
|
||||
window.top.postMessage(JSON.stringify(res), location.protocol + "//" + location.hostname);
|
||||
}
|
||||
|
||||
|
||||
}
|
113
bench/index.html
113
bench/index.html
@@ -1,113 +0,0 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Benchmark of Web Templating Engines (Non-Keyed)</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-weight: 300;
|
||||
line-height: 26px;
|
||||
font-size: 100%;
|
||||
background-color: #222;
|
||||
color: #bbb;
|
||||
}
|
||||
h1{
|
||||
padding-top: 10px;
|
||||
}
|
||||
input, select{
|
||||
padding: 5px 10px;
|
||||
}
|
||||
#benchmarks td{
|
||||
text-align: right;
|
||||
}
|
||||
#benchmarks td:first-of-type{
|
||||
text-align: left;
|
||||
}
|
||||
body.modes #benchmarks th:nth-last-child(1),
|
||||
body.modes #benchmarks td:nth-last-child(1),
|
||||
body.modes #benchmarks th:nth-last-child(2),
|
||||
body.modes #benchmarks td:nth-last-child(2){
|
||||
display:none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Benchmark of Full-Text-Search Libraries (Stress Test)</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" id="start" click="start" value="Start">
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
Mode:
|
||||
<select id="mode" change="mode">
|
||||
<option value>Simple</option>
|
||||
<option disabled>Advanced</option>
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
Duration:
|
||||
<select id="duration">
|
||||
<option value="0.1">100 ms</option>
|
||||
<option value="0.5">500 ms</option>
|
||||
<option value="1">1 sec</option>
|
||||
<option value="3">3 sec</option>
|
||||
<option value="5" selected>5 sec</option>
|
||||
<option value="10">10 sec</option>
|
||||
<option value="30">30 sec</option>
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
Repeat:
|
||||
<select id="repeat">
|
||||
<option value="1" selected>1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="5">5</option>
|
||||
<option value="10">10</option>
|
||||
<option value="25">25</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="checkbox" id="keep" checked> keep best run
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<table id="benchmarks" cellpadding="5" cellspacing="5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Library</th>
|
||||
<th hidden>Size</th>
|
||||
<th>Memory *</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result"></tbody>
|
||||
</table>
|
||||
<br>
|
||||
* To measure memory you have to run in Chrome browser.<br><br>
|
||||
<b>Single Tests:</b>
|
||||
<ul id="lib"></ul>
|
||||
<iframe id="iframe" hidden></iframe>
|
||||
<script src="https://rawcdn.githack.com/nextapps-de/mikado/0.7.4/dist/mikado.min.js"></script>
|
||||
<script src="tpl/row.js"></script>
|
||||
<script src="tpl/lib.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
348
bench/index.js
348
bench/index.js
@@ -1,348 +0,0 @@
|
||||
(function(){
|
||||
|
||||
"use strict";
|
||||
|
||||
const iframe = document.getElementById("iframe");
|
||||
const options = { cache: false, store: false, pool: false };
|
||||
const mikado = Mikado(document.getElementById("result"), "row", options);
|
||||
const list = Mikado(document.getElementById("lib"), "lib", options);
|
||||
|
||||
const modes = window.location.hash.indexOf("modes") !== -1;
|
||||
const encode = window.location.hash.indexOf("encode") !== -1;
|
||||
const update = window.location.hash.indexOf("update") !== -1;
|
||||
|
||||
let keep;
|
||||
let repeat;
|
||||
let index = -1;
|
||||
|
||||
let lib = shuffle(modes || encode ? [
|
||||
|
||||
"flexsearch-balance", "flexsearch-default", "flexsearch-fast",
|
||||
"flexsearch-match", "flexsearch-memory", "flexsearch-score",
|
||||
"flexsearch-speed"
|
||||
]:[
|
||||
/*"flexsearch-0.6.2", "flexsearch-0.6.3",*/ "minisearch", "flexsearch-0.7.0",
|
||||
"bm25", "bulksearch", "elasticlunr",
|
||||
"fuzzysearch", "js-search", "jsii",
|
||||
"fuse", "lunr", "wade", "lyra"
|
||||
]);
|
||||
|
||||
list.render(lib);
|
||||
|
||||
Mikado.route("start", function(target){
|
||||
|
||||
if(target.value === "Start"){
|
||||
|
||||
index = -1;
|
||||
repeat = document.getElementById("repeat").value;
|
||||
target.value = "Stop";
|
||||
setTimeout(runner, 200);
|
||||
}
|
||||
else{
|
||||
|
||||
current[index][test[2]] = "";
|
||||
target.value = "Start";
|
||||
iframe.src = "";
|
||||
index = lib.length;
|
||||
}
|
||||
|
||||
}).route("mode", function(target){
|
||||
|
||||
init(window.location.hash = "#" + target.value);
|
||||
|
||||
}).listen("click").listen("change");
|
||||
|
||||
const test = encode ? [
|
||||
|
||||
"size", "memory",
|
||||
"encode"
|
||||
|
||||
]: update ? [
|
||||
|
||||
"size", "memory",
|
||||
"add", "update", "remove",
|
||||
]:[
|
||||
"size", "memory",
|
||||
//"add",
|
||||
"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] = {
|
||||
|
||||
"name": lib[x],
|
||||
"size": 1, //size[lib[x]],
|
||||
"memory": 0,
|
||||
"score": "",
|
||||
"index": ""
|
||||
};
|
||||
|
||||
for(let y = 2; y < test.length + 1; y++){
|
||||
|
||||
current[x][test[y]] = "";
|
||||
current[x]["color_" + test[y]] = "transparent";
|
||||
}
|
||||
}
|
||||
|
||||
mikado.render(current);
|
||||
|
||||
function runner(){
|
||||
|
||||
const duration = document.getElementById("duration").value;
|
||||
keep = document.getElementById("keep").checked;
|
||||
|
||||
index++;
|
||||
const tmp = Object.assign({}, current[index]);
|
||||
tmp[test[2]] = "run...";
|
||||
mikado.update(mikado.node(index), tmp);
|
||||
iframe.src = "test/" + lib[index].toLowerCase() + "/" + "?duration=" + duration + (encode ? "&encode=true" : "");
|
||||
}
|
||||
|
||||
function get_score(){
|
||||
|
||||
let max = new Array(test.length);
|
||||
let val = new Array(test.length);
|
||||
|
||||
for(let y = 0; y < test.length; y++){
|
||||
|
||||
max[y] = 0;
|
||||
val[y] = [];
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
if(current[x][test[y]] && (current[x][test[y]] !== "-failed-")){
|
||||
|
||||
if(current[x][test[y]]){
|
||||
|
||||
val[y].push(current[x][test[y]]);
|
||||
}
|
||||
|
||||
if((test[y] === "size") || (test[y] === "memory")){
|
||||
|
||||
if((current[x][test[y]] < max[y]) || !max[y]){
|
||||
|
||||
max[y] = current[x][test[y]];
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if(current[x][test[y]] > max[y]){
|
||||
|
||||
max[y] = current[x][test[y]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let score = new Array(lib.length);
|
||||
let index = new Array(lib.length);
|
||||
let length = new Array(lib.length);
|
||||
let max_score = 0, max_index = 0;
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
score[x] = 0;
|
||||
index[x] = 0;
|
||||
length[x] = 0;
|
||||
|
||||
for(let y = 0; y < test.length; y++){
|
||||
|
||||
if(current[x][test[y]] && (current[x][test[y]] !== "-failed-")){
|
||||
|
||||
length[x]++;
|
||||
|
||||
if((test[y] === "size") || (test[y] === "memory")){
|
||||
|
||||
score[x] += Math.sqrt(median(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]);
|
||||
index[x] += current[x][test[y]] / max[y];
|
||||
current[x]["color_" + test[y]] = color(current[x][test[y]], max[y]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
current[x]["color_" + test[y]] = "#ccc";
|
||||
}
|
||||
}
|
||||
|
||||
current[x]["score"] = (score[x] / length[x] * 1000 + 0.5) | 0;
|
||||
current[x]["index"] = (index[x] / length[x] * 1000 + 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"];
|
||||
}
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
current[x]["color_score"] = color(current[x]["score"], max_score);
|
||||
current[x]["color_index"] = color(current[x]["index"], max_index);
|
||||
}
|
||||
}
|
||||
|
||||
function color(current, max){
|
||||
|
||||
const percent = current / max * 100;
|
||||
const r = percent < 50 ? 255 : (255 - (percent * 2 - 100) * 255 / 100) | 0;
|
||||
const g = percent > 50 ? 255 : ((percent * 2) * 255 / 100) | 0;
|
||||
|
||||
return 'rgb(' + r + ', ' + g + ', 0)';
|
||||
}
|
||||
|
||||
window.onmessage = function(event){
|
||||
|
||||
if(index < lib.length){
|
||||
|
||||
if(event.origin === location.protocol + "//" + location.hostname){ // "https://nextapps-de.github.io" "https://raw.githack.com"
|
||||
|
||||
//console.log(event.data);
|
||||
|
||||
const parts = event.data.split(",");
|
||||
|
||||
let tmp = parseInt(parts[1], 10);
|
||||
|
||||
if(keep){
|
||||
|
||||
if(!current[index][parts[0]] || (tmp > current[index][parts[0]])){
|
||||
|
||||
current[index][parts[0]] = tmp;
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if(current[index][parts[0]]){
|
||||
|
||||
current[index][parts[0]] += tmp;
|
||||
}
|
||||
else{
|
||||
|
||||
current[index][parts[0]] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = parseInt(parts[2], 10);
|
||||
|
||||
if(current[index]["memory"]){
|
||||
|
||||
current[index]["memory"] += tmp;
|
||||
}
|
||||
else{
|
||||
|
||||
current[index]["memory"] = tmp;
|
||||
}
|
||||
|
||||
if((repeat === 1) && (!current[index][parts[0]])){
|
||||
|
||||
current[index][parts[0]] = "-failed-";
|
||||
}
|
||||
|
||||
if(parts[0] === "not-found"){
|
||||
|
||||
if(index < lib.length - 1){
|
||||
|
||||
mikado.update(index, current[index]);
|
||||
setTimeout(runner, 50);
|
||||
}
|
||||
else{
|
||||
|
||||
get_score();
|
||||
|
||||
current.sort(function(a, b){
|
||||
|
||||
return b["score"] - a["score"];
|
||||
});
|
||||
|
||||
for(let i = 0; i < lib.length; i++){
|
||||
|
||||
lib[i] = current[i]["name"];
|
||||
}
|
||||
|
||||
mikado.render(current);
|
||||
|
||||
if(--repeat > 0){
|
||||
|
||||
index = -1;
|
||||
setTimeout(runner, 50);
|
||||
}
|
||||
else{
|
||||
|
||||
Mikado.dispatch("start", document.getElementById("start"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
const tmp = Object.assign({}, current[index]);
|
||||
tmp[test[test.indexOf(parts[0]) + 1]] = "run...";
|
||||
mikado.update(index, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function shuffle(items){
|
||||
|
||||
for(let i = items.length - 1, j, x; i > 0; i--) {
|
||||
|
||||
j = (Math.random() * i) | 0;
|
||||
x = items[i];
|
||||
items[i] = items[j];
|
||||
items[j] = x;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function median(arr){
|
||||
|
||||
arr.sort(function(a, b){
|
||||
|
||||
return a - b;
|
||||
});
|
||||
|
||||
const length = arr.length;
|
||||
const half = length / 2;
|
||||
|
||||
return (
|
||||
|
||||
length % 2 ?
|
||||
|
||||
arr[half | 0]
|
||||
:
|
||||
(arr[half - 1] + arr[half]) / 2
|
||||
);
|
||||
}
|
||||
|
||||
}());
|
@@ -1,39 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Matching Test</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Relevance Scoring Comparison</h2>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<div id="container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr style="font-weight: bold">
|
||||
<td style="width: 200px">Query</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="line-height: 2em">
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #f00"></div> Either no results or relevant content was not included in results.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: orange"></div> Most relevant results was not found in the first place.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #0a0"></div> Most relevant results was successfully found in the first place.<br>
|
||||
<b>Note:</b> Open console and type e.g. <i>data[493]</i>
|
||||
</div>
|
||||
<iframe id="iframe" hidden></iframe>
|
||||
<script type="module" src="match.js"></script>
|
||||
</body>
|
||||
</html>
|
150
bench/match.js
150
bench/match.js
@@ -1,150 +0,0 @@
|
||||
import { text_data } from "../demo/data/gulliver.js";
|
||||
|
||||
const iframe = document.getElementsByTagName("iframe")[0];
|
||||
const encode = false;
|
||||
const lib = encode ? [
|
||||
|
||||
"flexsearch-balance", "flexsearch-default", "flexsearch-fast",
|
||||
"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"
|
||||
];
|
||||
|
||||
let promise;
|
||||
|
||||
window.onmessage = function(event){
|
||||
|
||||
if(event.origin === location.protocol + "//" + location.hostname){
|
||||
|
||||
const results = JSON.parse(event.data);
|
||||
//console.log(results);
|
||||
promise(results);
|
||||
promise = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.data = text_data;
|
||||
|
||||
const tpl_td = document.createElement("td");
|
||||
tpl_td.appendChild(document.createTextNode(""))
|
||||
|
||||
const root_head = document.getElementsByTagName("thead")[0].firstElementChild,
|
||||
root_body = document.getElementsByTagName("tbody")[0];
|
||||
|
||||
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
|
||||
|
||||
const tr = tpl_tr.cloneNode(true);
|
||||
tr.id = "test-" + (i + 1);
|
||||
|
||||
root_body.appendChild(tr);
|
||||
root_head.appendChild(tpl_td.cloneNode(true));
|
||||
}
|
||||
|
||||
const headers = root_head.getElementsByTagName("td");
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
await do_test("test-1", "without breach of modesty", [2684]);
|
||||
await do_test("test-2", "went softly stream", [2432]);
|
||||
await do_test("test-3", "princes of the ambition", [2259, 396]);
|
||||
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]);
|
||||
await do_test("test-7", "bignes of splaknuk", [781]);
|
||||
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]);
|
||||
await do_test("test-12", "fast chief", [1275]);
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
async function do_test(id, query, ref){
|
||||
|
||||
const nodes = document.getElementById(id).getElementsByTagName("td");
|
||||
nodes[0].firstChild.nodeValue = query;
|
||||
|
||||
for(let i = 0, current; i < lib.length; i++){
|
||||
|
||||
current = lib[i].replace("-0.7.0", "").replace("-match", "");
|
||||
headers[i + 1].firstChild.nodeValue = current;
|
||||
|
||||
const node = nodes[i + 1];
|
||||
const style = node.style;
|
||||
|
||||
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";
|
||||
});
|
||||
|
||||
if(results.length){
|
||||
|
||||
switch(current){
|
||||
|
||||
case "elasticlunr":
|
||||
case "lunr":
|
||||
results = results.map(val => val.ref);
|
||||
break;
|
||||
|
||||
case "wade":
|
||||
results = results.map(val => val.index);
|
||||
break;
|
||||
|
||||
case "js-search":
|
||||
case "minisearch":
|
||||
case "jsii":
|
||||
case "bm25":
|
||||
results = results.map(val => val.id);
|
||||
break;
|
||||
|
||||
case "fuzzysearch":
|
||||
results = results.map(val => text_data.indexOf(val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(let a = 0; a < ref.length; a++){
|
||||
|
||||
const current = ref[a];
|
||||
|
||||
node.firstChild.nodeValue = results[0] || "-";
|
||||
style.color = "#fff";
|
||||
style.backgroundColor = "";
|
||||
|
||||
|
||||
if((results[a] === current) ||
|
||||
(results[a] === ("" + current))){
|
||||
|
||||
if(style.backgroundColor !== "orange"){
|
||||
|
||||
style.backgroundColor = "#0a0";
|
||||
}
|
||||
}
|
||||
else if(!results.length ||
|
||||
((results.indexOf(current) === -1) &&
|
||||
(results.indexOf(("" + current)) === -1))){
|
||||
|
||||
style.backgroundColor = "#f00";
|
||||
break;
|
||||
}
|
||||
else{
|
||||
|
||||
style.backgroundColor = "orange";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: bm25</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://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["bm25"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new BM25();
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
|
||||
lib.updateIdf();
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
|
||||
lib.updateIdf();
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
// not implemented
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -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>
|
@@ -1,54 +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.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>
|
@@ -1,50 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: elasticlunr-0.9.6</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/weixsong/elasticlunr.js@0.9.6/example/elasticlunr.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["elasticlunr"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = elasticlunr(function(){
|
||||
|
||||
this.addField("content");
|
||||
this.setRef("id");
|
||||
});
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.addDoc({ id: i, content: data[i] });
|
||||
}
|
||||
},
|
||||
update: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.addDoc({ id: i, content: data[i] });
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query, { expand: true });
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.6.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://rawcdn.githack.com/nextapps-de/flexsearch/0.6.22/dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch-0.6.2"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
resolution: 9,
|
||||
threshold: 8,
|
||||
depth: 1
|
||||
});
|
||||
|
||||
window["lib"] = lib;
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.6.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://rawcdn.githack.com/nextapps-de/flexsearch/0.6.32/dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch-0.6.3"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
resolution: 9,
|
||||
threshold: 8,
|
||||
depth: 1
|
||||
});
|
||||
|
||||
window["lib"] = lib;
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -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>
|
@@ -1,57 +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 { encode } from "../../../src/lang/latin/advanced.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,68 +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 src="../../../dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
//import Index from "../../../src/index.js";
|
||||
//import Document from "../../../src/document.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib, split = /[^a-z]+/;
|
||||
|
||||
suite["flexsearch-0.7.0"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch.Index({
|
||||
|
||||
encode: str => str.toLowerCase().split(split),
|
||||
tokenize: "strict",
|
||||
resolution: 1,
|
||||
minlength: 3,
|
||||
optimize: false,
|
||||
fastupdate: false,
|
||||
context: {
|
||||
depth: 1,
|
||||
bidirectional: false,
|
||||
resolution: 1
|
||||
}
|
||||
});
|
||||
},
|
||||
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, 9999);
|
||||
},
|
||||
update: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.update(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.remove(i, data[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -1,52 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: fuse-3.3.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 type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["fuse"] = {
|
||||
|
||||
init: function(){},
|
||||
add: function(data){
|
||||
|
||||
const length = data.length;
|
||||
const payload = new Array(length);
|
||||
|
||||
for(let i = 0; i < length; i++){
|
||||
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
lib = new Fuse(payload, {
|
||||
|
||||
keys: ['content'],
|
||||
id: 'id',
|
||||
shouldSort: true,
|
||||
threshold: 1,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
findAllMatches: true,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1
|
||||
});
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,49 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: fuse-3.3.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 type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["fuse"] = {
|
||||
|
||||
init: function(){},
|
||||
add: function(data){
|
||||
|
||||
const length = data.length;
|
||||
const payload = new Array(length);
|
||||
|
||||
for(let i = 0; i < length; i++){
|
||||
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
lib = new Fuse(payload, {
|
||||
|
||||
keys: ["content"],
|
||||
id: "id",
|
||||
shouldSort: true,
|
||||
tokenize: true,
|
||||
matchAllTokens: true,
|
||||
threshold: 0.2
|
||||
});
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,33 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: fuzzysearch</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/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["fuzzysearch"] = {
|
||||
|
||||
init: function(){},
|
||||
add: function(data){
|
||||
|
||||
lib = new FuzzySearch({source: data});
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: js-search-1.4.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/js-search@1.4.2/dist/umd/js-search.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["js-search"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new JsSearch.Search("id");
|
||||
lib.addIndex("content");
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
const payload = [];
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
lib.addDocuments(payload);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: jsii</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/karussell/jsii@master/web/js/src/BitSet.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["jsii"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new JSii();
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
const payload = [];
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
payload[i] = {
|
||||
|
||||
id: i,
|
||||
text: data[i]
|
||||
};
|
||||
}
|
||||
|
||||
lib.feedDocs(payload);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query).docs;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,49 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: lunr-2.3.5</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 type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["lunr"] = {
|
||||
|
||||
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.query(function(q) {
|
||||
|
||||
q.term(query, { wildcard: lunr.Query.wildcard.LEADING })
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,52 +0,0 @@
|
||||
<!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/lyra@0.2.4/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>
|
@@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: minisearch</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 type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["minisearch"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new MiniSearch({
|
||||
fields: ["text"],
|
||||
storeFields: ["id"]
|
||||
});
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.add({ id: i, text: data[i] });
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query, { prefix: true, fuzzy: 0.2 });
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: minisearch</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 type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["minisearch"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new MiniSearch({
|
||||
fields: ["text"],
|
||||
storeFields: ["id"]
|
||||
});
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.add({ id: i, text: data[i] });
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: wade-0.3.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/kbrsh/wade@0.3.3/dist/wade.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["wade"] = {
|
||||
|
||||
init: function(){},
|
||||
add: function(data){
|
||||
|
||||
lib = Wade(data);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib(query).sort(function(a, b){
|
||||
|
||||
const sum = a.score - b.score;
|
||||
return sum < 0 ? 1 : sum ? -1 : 0;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,3 +0,0 @@
|
||||
<li>
|
||||
<a href="test/{{data + '/'}}">{{data}}</a>
|
||||
</li>
|
@@ -1,17 +0,0 @@
|
||||
Mikado.register({
|
||||
"t": "li",
|
||||
"i": {
|
||||
"t": "a",
|
||||
"a": {
|
||||
"href": [
|
||||
"'test/' + data + '/'"
|
||||
]
|
||||
},
|
||||
"x": [
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"d": false,
|
||||
"n": "lib",
|
||||
"v": "0.7.44"
|
||||
});
|
@@ -1,12 +0,0 @@
|
||||
<tr>
|
||||
<td>{{data.name}}</td>
|
||||
<td style="background-color:{{data.color_size}}" hidden>{{data.size}}</td>
|
||||
<td style="background-color:{{data.color_memory}}">{{data.memory}}</td>
|
||||
<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_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>
|
||||
</tr>
|
104
bench/tpl/row.js
104
bench/tpl/row.js
@@ -1,104 +0,0 @@
|
||||
Mikado.register({
|
||||
"t": "tr",
|
||||
"i": [
|
||||
{
|
||||
"t": "td",
|
||||
"x": [
|
||||
"data.name"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"a": {
|
||||
"hidden": true
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_size"
|
||||
],
|
||||
"x": [
|
||||
"data.size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data.color_memory"
|
||||
],
|
||||
"x": [
|
||||
"data.memory"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-single']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-single']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-multi']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-multi']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-long']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-long']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-dupes']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-dupes']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_not-found']"
|
||||
],
|
||||
"x": [
|
||||
"data['not-found']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"i": {
|
||||
"t": "b",
|
||||
"x": [
|
||||
"data.index"
|
||||
]
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_index"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"i": {
|
||||
"t": "b",
|
||||
"x": [
|
||||
"data.score"
|
||||
]
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_score"
|
||||
]
|
||||
}
|
||||
],
|
||||
"d": false,
|
||||
"n": "row",
|
||||
"v": "0.7.44"
|
||||
});
|
Reference in New Issue
Block a user