Skip to content

Commit 13da159

Browse files
committed
Add BTree diffAgainst benchmarks
1 parent fb31d70 commit 13da159

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

benchmarks.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,28 @@ console.log("### Measure effect of max node size ###");
310310
tree.set(keys[i], undefined);
311311
console.log(`${timer.restart()}\tInsert ${tree.size} keys in B+tree with node size ${tree.maxNodeSize}`);
312312
}
313+
}
314+
315+
console.log();
316+
console.log("### Delta between B+ trees with various sizes");
317+
{
318+
console.log();
319+
const sizes = [100, 1000, 10000, 100000, 1000000];
320+
321+
sizes.forEach((size, i) => {
322+
for (let j = i; j < sizes.length; j++) {
323+
const tree = new BTree();
324+
for (let k of makeArray(size, true))
325+
tree.set(k, k * 10);
326+
327+
const otherSize = sizes[j];
328+
const otherTree = new BTree();
329+
for (let k of makeArray(otherSize, true))
330+
otherTree.set(k, k * 10);
331+
332+
measure(() => `Delta between B+tree with ${size} nodes and B+tree with ${otherSize} nodes`, () => {
333+
tree.diffAgainst(otherTree);
334+
});
335+
}
336+
})
313337
}

0 commit comments

Comments
 (0)