@contrail/util 1.1.15-alpha-10 → 1.1.15-alpha-11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.1.15-alpha-10",
3
+ "version": "1.1.15-alpha-11",
4
4
  "description": "General JavaScript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const lodash_1 = require("lodash");
4
- const cloneDeep_1 = require("./cloneDeep");
5
- function jsonClone(obj) {
6
- return JSON.parse(JSON.stringify(obj));
7
- }
8
- console.log('Performance test for small objects:');
9
- let smallObject = {
10
- sub1: {
11
- val: 1,
12
- },
13
- sub3: {
14
- val: 2,
15
- valX: '3',
16
- },
17
- };
18
- console.time('cloneDeepSmallRFDC');
19
- Array.from({ length: 10000 }).forEach(() => {
20
- (0, cloneDeep_1.cloneDeep)(smallObject);
21
- });
22
- console.timeEnd('cloneDeepSmallRFDC');
23
- console.time('cloneDeepSmallLodash');
24
- Array.from({ length: 10000 }).forEach(() => {
25
- (0, lodash_1.cloneDeep)(smallObject);
26
- });
27
- console.timeEnd('cloneDeepSmallLodash');
28
- console.time('cloneDeepSmallJson');
29
- Array.from({ length: 10000 }).forEach(() => {
30
- jsonClone(smallObject);
31
- });
32
- console.timeEnd('cloneDeepSmallJson');
33
- console.time('structuredCloneSmall');
34
- Array.from({ length: 10000 }).forEach(() => {
35
- structuredClone(smallObject);
36
- });
37
- console.timeEnd('structuredCloneSmall');
38
- console.log('\n\nPerformance test for very large objects:');
39
- let veryLargeObject = {};
40
- for (let i = 0; i < 100000; i++) {
41
- veryLargeObject[`key${i}`] = {
42
- sub1: {
43
- val: i,
44
- },
45
- sub2: new Date('2023-10-01T12:00:00.000Z'),
46
- sub3: {
47
- val: i + 1,
48
- valX: i + 2,
49
- },
50
- };
51
- }
52
- console.time('cloneDeepRFDC');
53
- (0, cloneDeep_1.cloneDeep)(veryLargeObject);
54
- console.timeEnd('cloneDeepRFDC');
55
- console.time('cloneDeepLodash');
56
- (0, lodash_1.cloneDeep)(veryLargeObject);
57
- console.timeEnd('cloneDeepLodash');
58
- console.time('cloneDeepJson');
59
- jsonClone(veryLargeObject);
60
- console.timeEnd('cloneDeepJson');
61
- console.time('structuredClone');
62
- structuredClone(veryLargeObject);
63
- console.timeEnd('structuredClone');
64
- console.log('\n\nPerformance test for very large arrays:');
65
- let veryLargeArray = [];
66
- for (let i = 0; i < 100000; i++) {
67
- veryLargeArray.push({
68
- sub1: {
69
- val: i,
70
- },
71
- sub2: new Date('2023-10-01T12:00:00.000Z'),
72
- sub3: {
73
- val: i + 1,
74
- valX: i + 2,
75
- },
76
- });
77
- }
78
- console.time('cloneDeepArrayRFDC');
79
- (0, cloneDeep_1.cloneDeep)(veryLargeArray);
80
- console.timeEnd('cloneDeepArrayRFDC');
81
- console.time('cloneDeepArrayLodash');
82
- (0, lodash_1.cloneDeep)(veryLargeArray);
83
- console.timeEnd('cloneDeepArrayLodash');
84
- console.time('cloneDeepArrayJson');
85
- jsonClone(veryLargeArray);
86
- console.timeEnd('cloneDeepArrayJson');
87
- console.time('structuredCloneArray');
88
- structuredClone(veryLargeArray);
89
- console.timeEnd('structuredCloneArray');
90
- console.log('\n\nPerformance test for assortment.json:');
91
- const fs = require("fs");
92
- const path = require("path");
93
- const assortmentFilePath = path.join(__dirname, 'assortment.json');
94
- const assortmentData = JSON.parse(fs.readFileSync(assortmentFilePath, 'utf8'));
95
- console.time('cloneDeepAssortment25kRFDC');
96
- (0, cloneDeep_1.cloneDeep)(assortmentData);
97
- console.timeEnd('cloneDeepAssortment25kRFDC');
98
- console.time('cloneDeepAssortment25kLodash');
99
- (0, lodash_1.cloneDeep)(assortmentData);
100
- console.timeEnd('cloneDeepAssortment25kLodash');
101
- console.time('cloneDeepAssortment25kJson');
102
- jsonClone(assortmentData);
103
- console.timeEnd('cloneDeepAssortment25kJson');
104
- console.time('structuredCloneAssortment25k');
105
- structuredClone(assortmentData);
106
- console.timeEnd('structuredCloneAssortment25k');