-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuseTest.js
37 lines (31 loc) · 879 Bytes
/
fuseTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function getFuseIndex(data) {
const keys = ['startDate', 'endDate', 'title', 'artists', 'location', 'alternativeName', 'remarks'];
const p1 = performance.now();
const index = Fuse.createIndex(keys, data)
const fuse = new Fuse(data, {keys, useExtendedSearch: true}, index);
const p2 = performance.now();
return {
time: (p2 - p1),
index: fuse,
};
}
function useFuseLocation(data, index) {
const p1 = performance.now();
let res = index.search("'Weimar");
const p2 = performance.now();
return {
time: (p2 - p1),
items: res,
count: res.length,
};
}
function useFuseFullText(data, index) {
const p1 = performance.now();
let res = index.search("'Paulus");
const p2 = performance.now();
return {
time: (p2 - p1),
items: res,
count: res.length,
};
}