forked from eslachance/djs-collection-persistent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
32 lines (24 loc) · 785 Bytes
/
test.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
const PersistentCollection = require("./index");
const myColl = new PersistentCollection({name: "test"});
myColl.waitUntil(()=>this.ready, ()=>{
console.time("100kInserts");
for(let i = 0; i<100000;i++) {
myColl.set(`test${i}`, {testValue: "This is a test Value"});
}
console.timeEnd("100kInserts");
myColl.waitUntil(
() => myColl.inProgress = 0,
() => {
console.time("10kRandoms");
myColl.randomKey(10000);
console.timeEnd("10kRandoms");
console.time("DeleteAll");
const arrPromises = myColl.deleteAll();
Promise.all(arrPromises).then(() => {
console.timeEnd("DeleteAll");
});
});
});
process.on("unhandledRejection", err => {
console.error("Uncaught Promise Error: ", err);
});