diff --git a/README.md b/README.md
index 9f977bb..d626833 100644
--- a/README.md
+++ b/README.md
@@ -728,40 +728,49 @@ optimal approach to data structure design.
[//]: # (No deletion!!! Start of Replace Section)
avl-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 32.23 | 31.03 | 0.00 |
10,000 add & delete randomly | 72.19 | 13.85 | 0.00 |
10,000 addMany | 41.39 | 24.16 | 9.33e-4 |
10,000 get | 28.05 | 35.66 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 31.34 | 31.90 | 3.63e-4 |
10,000 add & delete randomly | 71.68 | 13.95 | 0.00 |
10,000 addMany | 48.63 | 20.56 | 0.01 |
10,000 get | 28.99 | 34.49 | 0.00 |
binary-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 add randomly | 12.56 | 79.59 | 6.46e-4 |
1,000 add & delete randomly | 16.15 | 61.91 | 7.18e-4 |
1,000 addMany | 10.64 | 93.95 | 6.17e-4 |
1,000 get | 18.44 | 54.22 | 4.23e-4 |
1,000 dfs | 160.17 | 6.24 | 0.01 |
1,000 bfs | 57.41 | 17.42 | 0.00 |
1,000 morris | 264.54 | 3.78 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 add randomly | 12.47 | 80.21 | 2.46e-4 |
1,000 add & delete randomly | 16.29 | 61.39 | 0.00 |
1,000 addMany | 10.34 | 96.67 | 1.78e-4 |
1,000 get | 22.72 | 44.02 | 0.01 |
1,000 dfs | 167.13 | 5.98 | 0.01 |
1,000 bfs | 57.06 | 17.53 | 4.63e-4 |
1,000 morris | 272.80 | 3.67 | 0.01 |
bst
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 28.45 | 35.15 | 4.14e-4 |
10,000 add & delete randomly | 67.78 | 14.75 | 0.00 |
10,000 addMany | 29.04 | 34.43 | 5.76e-4 |
10,000 get | 28.67 | 34.88 | 8.26e-4 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 30.28 | 33.02 | 4.41e-4 |
10,000 add & delete randomly | 73.93 | 13.53 | 0.01 |
10,000 addMany | 29.66 | 33.72 | 0.00 |
10,000 get | 27.96 | 35.76 | 3.35e-4 |
rb-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 add randomly | 90.96 | 10.99 | 0.01 |
100,000 competitor add randomly | 50.10 | 19.96 | 0.01 |
100,000 add & delete randomly | 219.06 | 4.56 | 0.01 |
100,000 getNode | 106.06 | 9.43 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 add randomly | 89.26 | 11.20 | 0.01 |
100,000 add & delete randomly | 218.90 | 4.57 | 0.01 |
100,000 getNode | 41.74 | 23.96 | 0.00 |
directed-graph
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 addVertex | 0.11 | 9433.92 | 4.40e-6 |
1,000 addEdge | 6.24 | 160.30 | 2.02e-4 |
1,000 getVertex | 0.05 | 2.13e+4 | 1.64e-6 |
1,000 getEdge | 23.80 | 42.02 | 0.00 |
tarjan | 218.46 | 4.58 | 0.01 |
tarjan all | 221.95 | 4.51 | 0.00 |
topologicalSort | 183.70 | 5.44 | 0.01 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 addVertex | 0.10 | 9995.32 | 1.43e-6 |
1,000 addEdge | 6.32 | 158.28 | 7.89e-4 |
1,000 getVertex | 0.05 | 2.17e+4 | 2.66e-7 |
1,000 getEdge | 23.68 | 42.23 | 0.00 |
tarjan | 214.15 | 4.67 | 0.01 |
tarjan all | 214.51 | 4.66 | 0.00 |
topologicalSort | 182.64 | 5.48 | 0.01 |
+
+
hash-map
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 set | 16.51 | 60.57 | 9.87e-4 |
10,000 set & get | 34.75 | 28.77 | 6.11e-4 |
heap
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add & pop | 4.63 | 215.97 | 4.50e-5 |
10,000 fib add & pop | 359.98 | 2.78 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add & pop | 4.62 | 216.34 | 4.19e-5 |
10,000 fib add & pop | 358.77 | 2.79 | 0.00 |
doubly-linked-list
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 unshift | 233.68 | 4.28 | 0.06 |
1,000,000 unshift & shift | 185.63 | 5.39 | 0.05 |
1,000,000 insertBefore | 321.19 | 3.11 | 0.04 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 unshift | 232.43 | 4.30 | 0.09 |
1,000,000 unshift & shift | 174.59 | 5.73 | 0.05 |
1,000,000 insertBefore | 322.71 | 3.10 | 0.07 |
singly-linked-list
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 push & pop | 217.95 | 4.59 | 0.01 |
10,000 insertBefore | 248.81 | 4.02 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 push & pop | 216.35 | 4.62 | 0.01 |
10,000 insertBefore | 246.91 | 4.05 | 0.00 |
max-priority-queue
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 refill & poll | 11.72 | 85.30 | 2.79e-4 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 refill & poll | 11.67 | 85.71 | 2.89e-4 |
+
+
priority-queue
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add & pop | 12.43 | 80.44 | 1.15e-4 |
deque
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 204.13 | 4.90 | 0.04 |
1,000,000 shift | 25.71 | 38.89 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 222.16 | 4.50 | 0.06 |
1,000,000 shift | 26.33 | 37.98 | 0.00 |
queue
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 42.93 | 23.30 | 0.00 |
1,000,000 push & shift | 80.12 | 12.48 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 45.99 | 21.74 | 0.01 |
1,000,000 push & shift | 80.49 | 12.42 | 0.00 |
+
+
stack
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 44.04 | 22.71 | 0.01 |
1,000,000 push & pop | 50.06 | 19.98 | 0.01 |
trie
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 push | 56.09 | 17.83 | 0.00 |
100,000 getWords | 97.76 | 10.23 | 0.01 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 push | 44.87 | 22.29 | 7.28e-4 |
100,000 getWords | 88.45 | 11.31 | 0.00 |
[//]: # (No deletion!!! End of Replace Section)
\ No newline at end of file
diff --git a/package.json b/package.json
index ca7ae2a..bfbe76a 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"install:all-subs": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multimap-typed trie-typed undirected-graph-typed queue-typed --save-dev",
"test": "jest --runInBand",
"test:integration": "npm run update:subs && jest --config jest.integration.config.js",
- "benchmark": "ts-node test/performance/reportor.ts",
+ "test:perf": "ts-node test/performance/reportor.ts",
"check:deps": "dependency-cruiser src",
"changelog": "auto-changelog",
"coverage:badge": "istanbul-badges-readme",
diff --git a/test/config.ts b/test/config.ts
index 6ca1161..fc676fe 100644
--- a/test/config.ts
+++ b/test/config.ts
@@ -1 +1,2 @@
export const isDebugTest = false;
+export const isCompetitor = false;
diff --git a/test/performance/data-structures/binary-tree/rb-tree.test.ts b/test/performance/data-structures/binary-tree/rb-tree.test.ts
index 2eb72f9..7e4d60c 100644
--- a/test/performance/data-structures/binary-tree/rb-tree.test.ts
+++ b/test/performance/data-structures/binary-tree/rb-tree.test.ts
@@ -2,6 +2,7 @@ import {RedBlackTree} from '../../../../src';
import * as Benchmark from 'benchmark';
import {getRandomIntArray, magnitude} from '../../../utils';
import {OrderedMap} from 'js-sdsl';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
const rbTree = new RedBlackTree();
@@ -15,21 +16,26 @@ suite
for (let i = 0; i < arr.length; i++) {
rbTree.add(arr[i]);
}
- })
- .add(`${HUNDRED_THOUSAND.toLocaleString()} competitor add randomly`, () => {
+ });
+
+
+if (isCompetitor) {
+ suite.add(`${HUNDRED_THOUSAND.toLocaleString()} competitor add randomly`, () => {
for (let i = 0; i < arr.length; i++) {
competitor.setElement(arr[i], arr[i]);
}
})
- .add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete randomly`, () => {
- rbTree.clear();
- for (let i = 0; i < arr.length; i++) {
- rbTree.add(arr[i]);
- }
- for (let i = 0; i < arr.length; i++) {
- rbTree.delete(arr[i]);
- }
- })
+}
+
+suite.add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete randomly`, () => {
+ rbTree.clear();
+ for (let i = 0; i < arr.length; i++) {
+ rbTree.add(arr[i]);
+ }
+ for (let i = 0; i < arr.length; i++) {
+ rbTree.delete(arr[i]);
+ }
+})
.add(`${HUNDRED_THOUSAND.toLocaleString()} getNode`, () => {
for (let i = 0; i < arr.length; i++) {
rbTree.getNode(arr[i]);
diff --git a/test/performance/data-structures/hash/hash-map.test.ts b/test/performance/data-structures/hash/hash-map.test.ts
index 703b76f..e9f1c91 100644
--- a/test/performance/data-structures/hash/hash-map.test.ts
+++ b/test/performance/data-structures/hash/hash-map.test.ts
@@ -2,44 +2,50 @@ import {HashMap} from '../../../../src';
import {HashMap as CHashMap} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
-const {LINEAR} = magnitude;
+const {TEN_THOUSAND} = magnitude;
suite
- .add(`${LINEAR.toLocaleString()} set`, () => {
+ .add(`${TEN_THOUSAND.toLocaleString()} set`, () => {
const hm = new HashMap();
- for (let i = 0; i < LINEAR; i++) {
+ for (let i = 0; i < TEN_THOUSAND; i++) {
hm.set(i, i);
}
- })
- .add(`${LINEAR.toLocaleString()} competitor set`, () => {
- const hm = new CHashMap();
-
- for (let i = 0; i < LINEAR; i++) {
- hm.setElement(i, i);
- }
- })
- .add(`${LINEAR.toLocaleString()} set & get`, () => {
- const hm = new HashMap();
-
- for (let i = 0; i < LINEAR; i++) {
- hm.set(i, i);
- }
- for (let i = 0; i < LINEAR; i++) {
- hm.get(i);
- }
- })
- .add(`${LINEAR.toLocaleString()} competitor set & get`, () => {
- const hm = new CHashMap();
-
- for (let i = 0; i < LINEAR; i++) {
- hm.setElement(i, i);
- }
- for (let i = 0; i < LINEAR; i++) {
- hm.getElementByKey(i);
- }
});
+if (isCompetitor) {
+ suite.add(`${TEN_THOUSAND.toLocaleString()} competitor set`, () => {
+ const hm = new CHashMap();
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ hm.setElement(i, i);
+ }
+ })
+}
+suite.add(`${TEN_THOUSAND.toLocaleString()} set & get`, () => {
+ const hm = new HashMap();
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ hm.set(i, i);
+ }
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ hm.get(i);
+ }
+})
+;
+if (isCompetitor) {
+ suite.add(`${TEN_THOUSAND.toLocaleString()} competitor set & get`, () => {
+ const hm = new CHashMap();
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ hm.setElement(i, i);
+ }
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ hm.getElementByKey(i);
+ }
+ })
+}
export {suite};
diff --git a/test/performance/data-structures/linked-list/doubly-linked-list.test.ts b/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
index 3911fd9..e25be19 100644
--- a/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
+++ b/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
@@ -2,6 +2,7 @@ import {DoublyLinkedList, DoublyLinkedListNode} from '../../../../src';
import {LinkList as CLinkedList} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
const {LINEAR} = magnitude;
@@ -14,14 +15,16 @@ suite
list.unshift(i);
}
})
- .add(`${LINEAR.toLocaleString()} competitor unshift`, () => {
- const list = new CLinkedList();
+ if (isCompetitor) {
+ suite.add(`${LINEAR.toLocaleString()} competitor unshift`, () => {
+ const list = new CLinkedList();
- for (let i = 0; i < LINEAR; i++) {
- list.pushFront(i);
- }
- })
- .add(`${LINEAR.toLocaleString()} unshift & shift`, () => {
+ for (let i = 0; i < LINEAR; i++) {
+ list.pushFront(i);
+ }
+ })
+ }
+ suite.add(`${LINEAR.toLocaleString()} unshift & shift`, () => {
const list = new DoublyLinkedList();
for (let i = 0; i < LINEAR; i++) {
diff --git a/test/performance/data-structures/priority-queue/priority-queue.test.ts b/test/performance/data-structures/priority-queue/priority-queue.test.ts
index 04808f2..b8f8693 100644
--- a/test/performance/data-structures/priority-queue/priority-queue.test.ts
+++ b/test/performance/data-structures/priority-queue/priority-queue.test.ts
@@ -2,6 +2,7 @@ import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
import {PriorityQueue} from '../../../../src';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
const {TEN_THOUSAND} = magnitude;
@@ -17,8 +18,9 @@ suite
for (let i = 0; i < TEN_THOUSAND; i++) {
pq.pop();
}
- })
- .add(`${TEN_THOUSAND.toLocaleString()} competitor add & pop`, () => {
+ });
+if (isCompetitor) {
+ suite.add(`${TEN_THOUSAND.toLocaleString()} competitor add & pop`, () => {
const pq = new CPriorityQueue();
for (let i = 0; i < TEN_THOUSAND; i++) {
@@ -30,4 +32,6 @@ suite
}
});
+}
+
export {suite};
diff --git a/test/performance/data-structures/queue/deque.test.ts b/test/performance/data-structures/queue/deque.test.ts
index a0bde90..3d6b774 100644
--- a/test/performance/data-structures/queue/deque.test.ts
+++ b/test/performance/data-structures/queue/deque.test.ts
@@ -2,6 +2,7 @@ import {Deque} from '../../../../src';
import {Deque as CDeque} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
export const suite = new Benchmark.Suite();
const {LINEAR} = magnitude;
@@ -13,13 +14,15 @@ suite
deque.push(i);
}
})
- .add(`${LINEAR.toLocaleString()} competitor push`, () => {
- const deque = new CDeque();
- for (let i = 0; i < LINEAR; i++) {
- deque.pushBack(i);
- }
- })
- .add(`${LINEAR.toLocaleString()} shift`, () => {
+ if (isCompetitor) {
+ suite.add(`${LINEAR.toLocaleString()} competitor push`, () => {
+ const deque = new CDeque();
+ for (let i = 0; i < LINEAR; i++) {
+ deque.pushBack(i);
+ }
+ })
+ }
+ suite.add(`${LINEAR.toLocaleString()} shift`, () => {
const deque = new Deque();
for (let i = 0; i < LINEAR; i++) {
deque.push(i);
diff --git a/test/performance/data-structures/queue/queue.test.ts b/test/performance/data-structures/queue/queue.test.ts
index 93e32a2..4e806a1 100644
--- a/test/performance/data-structures/queue/queue.test.ts
+++ b/test/performance/data-structures/queue/queue.test.ts
@@ -2,6 +2,7 @@ import {Queue} from '../../../../src';
import {Queue as CQueue} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
const {LINEAR} = magnitude;
@@ -14,14 +15,16 @@ suite
queue.push(i);
}
})
- .add(`${LINEAR.toLocaleString()} competitor push`, () => {
- const queue = new CQueue();
+ if (isCompetitor) {
+ suite.add(`${LINEAR.toLocaleString()} competitor push`, () => {
+ const queue = new CQueue();
- for (let i = 0; i < LINEAR; i++) {
- queue.push(i);
- }
- })
- .add(`${LINEAR.toLocaleString()} push & shift`, () => {
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ })
+ }
+ suite.add(`${LINEAR.toLocaleString()} push & shift`, () => {
const queue = new Queue();
for (let i = 0; i < LINEAR; i++) {
diff --git a/test/performance/data-structures/stack/stack.test.ts b/test/performance/data-structures/stack/stack.test.ts
index ec3c24d..0e4f89d 100644
--- a/test/performance/data-structures/stack/stack.test.ts
+++ b/test/performance/data-structures/stack/stack.test.ts
@@ -2,6 +2,7 @@ import {Stack} from '../../../../src';
import {Stack as CStack} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
+import {isCompetitor} from "../../../config";
const suite = new Benchmark.Suite();
const {LINEAR} = magnitude;
@@ -14,24 +15,27 @@ suite
stack.push(i);
}
})
- .add(`${LINEAR.toLocaleString()} competitor push`, () => {
+if (isCompetitor) {
+ suite.add(`${LINEAR.toLocaleString()} competitor push`, () => {
const queue = new CStack();
for (let i = 0; i < LINEAR; i++) {
queue.push(i);
}
})
- .add(`${LINEAR.toLocaleString()} push & pop`, () => {
- const queue = new Stack();
+}
+suite.add(`${LINEAR.toLocaleString()} push & pop`, () => {
+ const queue = new Stack();
- for (let i = 0; i < LINEAR; i++) {
- queue.push(i);
- }
- for (let i = 0; i < LINEAR; i++) {
- queue.pop();
- }
- })
- .add(`${LINEAR.toLocaleString()} competitor push & pop`, () => {
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ for (let i = 0; i < LINEAR; i++) {
+ queue.pop();
+ }
+})
+if (isCompetitor) {
+ suite.add(`${LINEAR.toLocaleString()} competitor push & pop`, () => {
const queue = new CStack();
for (let i = 0; i < LINEAR; i++) {
@@ -40,6 +44,7 @@ suite
for (let i = 0; i < LINEAR; i++) {
queue.pop();
}
- });
+ })
+}
export {suite};