data-structure-typed 1.41.2 → 1.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/benchmark/report.json +30 -0
  3. package/jest.integration.config.js +5 -0
  4. package/package.json +10 -6
  5. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +0 -0
  6. package/test/performance/data-structures/binary-tree/binary-index-tree.test.ts +0 -0
  7. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +0 -0
  8. package/test/performance/data-structures/binary-tree/bst.test.ts +0 -0
  9. package/test/performance/data-structures/binary-tree/overall.test.ts +0 -0
  10. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +0 -0
  11. package/test/performance/data-structures/binary-tree/segment-tree.test.ts +0 -0
  12. package/test/performance/data-structures/binary-tree/tree-multiset.test.ts +0 -0
  13. package/test/performance/data-structures/graph/abstract-graph.test.ts +0 -0
  14. package/test/performance/data-structures/graph/directed-graph.test.ts +0 -0
  15. package/test/performance/data-structures/graph/map-graph.test.ts +0 -0
  16. package/test/performance/data-structures/graph/overall.test.ts +0 -0
  17. package/test/performance/data-structures/graph/undirected-graph.test.ts +0 -0
  18. package/test/performance/data-structures/hash/coordinate-map.test.ts +0 -0
  19. package/test/performance/data-structures/hash/coordinate-set.test.ts +0 -0
  20. package/test/performance/data-structures/hash/hash-map.test.ts +0 -0
  21. package/test/performance/data-structures/hash/hash-table.test.ts +0 -0
  22. package/test/performance/data-structures/heap/heap.test.ts +0 -0
  23. package/test/performance/data-structures/heap/max-heap.test.ts +0 -0
  24. package/test/performance/data-structures/heap/min-heap.test.ts +0 -0
  25. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +0 -0
  26. package/test/performance/data-structures/linked-list/linked-list.test.ts +0 -0
  27. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +0 -0
  28. package/test/performance/data-structures/linked-list/skip-linked-list.test.ts +0 -0
  29. package/test/performance/data-structures/linked-list/skip-list.test.ts +0 -0
  30. package/test/performance/data-structures/matrix/matrix.test.ts +0 -0
  31. package/test/performance/data-structures/matrix/matrix2d.test.ts +0 -0
  32. package/test/performance/data-structures/matrix/navigator.test.ts +0 -0
  33. package/test/performance/data-structures/matrix/vector2d.test.ts +0 -0
  34. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +0 -0
  35. package/test/performance/data-structures/priority-queue/min-priority-queue.test.ts +0 -0
  36. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +0 -0
  37. package/test/performance/data-structures/queue/deque.test.ts +19 -0
  38. package/test/performance/data-structures/queue/queue.test.ts +20 -0
  39. package/test/performance/data-structures/stack/stack.test.ts +0 -0
  40. package/test/performance/data-structures/tree/tree.test.ts +0 -0
  41. package/test/performance/data-structures/trie/trie.test.ts +0 -0
  42. package/test/performance/index.ts +47 -0
  43. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
8
8
  - [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
9
9
  - [`auto-changelog`](https://github.com/CookPete/auto-changelog)
10
10
 
11
- ## [v1.41.2](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
11
+ ## [v1.41.3](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
12
12
 
13
13
  ### Changes
14
14
 
@@ -0,0 +1,30 @@
1
+ {
2
+ "queue": [
3
+ {
4
+ "name": "push",
5
+ "periodMS": 40.07764016666667,
6
+ "hz": 24.951568900798677,
7
+ "count": 2,
8
+ "mean": 0.04007764016666667,
9
+ "deviation": 0.0013167136100767647
10
+ }
11
+ ],
12
+ "deque": [
13
+ {
14
+ "name": "push",
15
+ "periodMS": 0.00026872424668883366,
16
+ "hz": 3721286.829609906,
17
+ "count": 236304,
18
+ "mean": 2.6872424668883365e-7,
19
+ "deviation": 1.2345296355979922e-7
20
+ },
21
+ {
22
+ "name": "shift",
23
+ "periodMS": 0.0002507354923627542,
24
+ "hz": 3988266.6413785545,
25
+ "count": 202308,
26
+ "mean": 2.5073549236275423e-7,
27
+ "deviation": 2.847150215172623e-9
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ testMatch: ['<rootDir>/test/integration/**/*.test.ts', '<rootDir>/test/integration/**/*.test.js'],
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.41.2",
3
+ "version": "1.41.3",
4
4
  "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/mjs/index.js",
@@ -32,10 +32,12 @@
32
32
  "update:subs": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed --save-dev",
33
33
  "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-multiset-typed trie-typed undirected-graph-typed queue-typed --save-dev",
34
34
  "test": "jest",
35
+ "test:integration": "npm run update:subs && jest --config jest.integration.config.js",
36
+ "benchmark": "ts-node test/performance/index.ts",
35
37
  "check:deps": "dependency-cruiser src",
36
38
  "changelog": "auto-changelog",
37
39
  "coverage:badge": "istanbul-badges-readme",
38
- "ci": "env && git fetch --tags && npm run check && npm run lint && npm run build && npm run update:subs && npm run test && npm run changelog",
40
+ "ci": "env && git fetch --tags && npm run check && npm run lint && npm run build && npm run test && npm run changelog",
39
41
  "copy:to-subs": "sh scripts/copy_to_all_subs.sh",
40
42
  "publish:subs": "npm run copy:to-subs && sh scripts/publish_all_subs.sh",
41
43
  "publish:docs": "sh scripts/publish_docs.sh",
@@ -61,22 +63,24 @@
61
63
  "@typescript-eslint/eslint-plugin": "^6.7.4",
62
64
  "@typescript-eslint/parser": "^6.7.4",
63
65
  "auto-changelog": "^2.4.0",
64
- "avl-tree-typed": "^1.41.1",
66
+ "avl-tree-typed": "^1.41.2",
65
67
  "benchmark": "^2.1.4",
66
- "binary-tree-typed": "^1.41.1",
67
- "bst-typed": "^1.41.1",
68
+ "binary-tree-typed": "^1.41.2",
69
+ "bst-typed": "^1.41.2",
68
70
  "dependency-cruiser": "^14.1.0",
69
71
  "eslint": "^8.50.0",
70
72
  "eslint-config-prettier": "^9.0.0",
71
73
  "eslint-import-resolver-alias": "^1.1.2",
72
74
  "eslint-import-resolver-typescript": "^3.6.1",
73
75
  "eslint-plugin-import": "^2.28.1",
74
- "heap-typed": "^1.41.1",
76
+ "fast-glob": "^3.3.1",
77
+ "heap-typed": "^1.41.2",
75
78
  "istanbul-badges-readme": "^1.8.5",
76
79
  "jest": "^29.7.0",
77
80
  "prettier": "^3.0.3",
78
81
  "ts-jest": "^29.1.1",
79
82
  "ts-loader": "^9.4.4",
83
+ "ts-node": "^10.9.1",
80
84
  "tsup": "^7.2.0",
81
85
  "typedoc": "^0.25.1",
82
86
  "typescript": "^5.2.2"
@@ -0,0 +1,19 @@
1
+ import {Deque} from "../../../../src";
2
+ import * as Benchmark from 'benchmark';
3
+
4
+ export const suite = new Benchmark.Suite();
5
+
6
+ suite
7
+ .add('push', () => {
8
+ const deque = new Deque<number>();
9
+ for (let i = 0; i < 10; i++) {
10
+ deque.push(i);
11
+ }
12
+ })
13
+ .add('shift', () => {
14
+ const deque = new Deque<number>();
15
+ for (let i = 0; i < 10; i++) {
16
+ deque.push(i);
17
+ deque.shift();
18
+ }
19
+ })
@@ -0,0 +1,20 @@
1
+ import {Queue} from "../../../../src";
2
+
3
+ import * as Benchmark from 'benchmark';
4
+
5
+ export const suite = new Benchmark.Suite();
6
+
7
+ suite
8
+ .add('push', () => {
9
+ const queue = new Queue<number>();
10
+ for (let i = 0; i < 1000000; i++) {
11
+ queue.push(i);
12
+ }
13
+ })
14
+ // .add('shift', () => {
15
+ // const queue = new Queue<number>();
16
+ // for (let i = 0; i < 10000; i++) {
17
+ // queue.push(i);
18
+ // queue.shift();
19
+ // }
20
+ // })
@@ -0,0 +1,47 @@
1
+ import * as Benchmark from 'benchmark';
2
+ import * as path from 'path';
3
+ import * as fs from 'fs';
4
+ import * as fastGlob from 'fast-glob';
5
+
6
+ const reportDistPath = 'benchmark';
7
+ const testDir = path.join(__dirname, 'data-structures');
8
+ const testFiles = fastGlob.sync(path.join(testDir, '**', '*.test.ts'));
9
+
10
+ const report: {[key: string] : any} = {};
11
+
12
+ let i = 0;
13
+ testFiles.forEach((file: string) => {
14
+ i++;
15
+ console.log(`testing file ${file}`);
16
+ const testName = path.basename(file, '.test.ts');
17
+ const testFunction = require(file);
18
+ const {suite} = testFunction;
19
+
20
+ if (suite) {
21
+ suite.on('cycle', (event: any) => {
22
+ console.log(String(event.target));
23
+ });
24
+
25
+ suite.on('complete', function (this: Benchmark.Suite) {
26
+ console.log('Fastest is ' + this.filter('fastest').map('name'));
27
+ report[testName] = this.map((test: Benchmark) => ({
28
+ name: test.name,
29
+ periodMS: test.times.period * 1000,
30
+ hz: test.hz,
31
+ count: test.count,
32
+ mean: test.stats.mean,
33
+ deviation: test.stats.deviation,
34
+ }));
35
+ // report[testName] = this;
36
+ console.log('----i', i, testFiles.length)
37
+ if (testFiles.length === i) {
38
+ if (!fs.existsSync(reportDistPath)) fs.mkdirSync(reportDistPath, { recursive: true });
39
+
40
+ const filePath = path.join(reportDistPath, 'report.json');
41
+ fs.writeFileSync(filePath, JSON.stringify(report, null, 2));
42
+ console.log('Performance test report file generated')
43
+ }
44
+ })
45
+ .run({async: true});
46
+ }
47
+ });
@@ -427,7 +427,7 @@ describe('RedBlackTree', () => {
427
427
  });
428
428
 
429
429
  it('should fix the tree after insertion and deletion', () => {
430
- for (let i = 0; i < 1000; i++) {
430
+ for (let i = 0; i < 100; i++) {
431
431
  tree.insert(getRandomInt(-100, 1000));
432
432
  tree.delete(getRandomInt(-100, 1000));
433
433
  }