@lowdefy/build 0.0.0-experimental-20251203181051 → 0.0.0-experimental-20251203183323

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.
@@ -12,41 +12,114 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function createBuildProfiler({ logger }) {
16
- const timings = [];
15
+ */ function createBuildProfiler({ logger, prefix = '' }) {
16
+ const timings = new Map();
17
17
  const isDebug = logger?.level === 'debug';
18
+ const track = (name)=>{
19
+ if (!isDebug) {
20
+ return;
21
+ }
22
+ if (!timings.has(name)) {
23
+ timings.set(name, {
24
+ total: 0,
25
+ count: 0,
26
+ min: Infinity,
27
+ max: 0
28
+ });
29
+ }
30
+ };
18
31
  const time = async (name, fn)=>{
19
32
  if (!isDebug) {
20
33
  return fn();
21
34
  }
35
+ track(name);
22
36
  const start = performance.now();
23
37
  const result = await fn();
24
38
  const duration = performance.now() - start;
25
- timings.push({
26
- name,
27
- duration
39
+ const entry = timings.get(name);
40
+ entry.total += duration;
41
+ entry.count += 1;
42
+ entry.min = Math.min(entry.min, duration);
43
+ entry.max = Math.max(entry.max, duration);
44
+ return result;
45
+ };
46
+ const timeSync = (name, fn)=>{
47
+ if (!isDebug) {
48
+ return fn();
49
+ }
50
+ track(name);
51
+ const start = performance.now();
52
+ const result = fn();
53
+ const duration = performance.now() - start;
54
+ const entry = timings.get(name);
55
+ entry.total += duration;
56
+ entry.count += 1;
57
+ entry.min = Math.min(entry.min, duration);
58
+ entry.max = Math.max(entry.max, duration);
59
+ return result;
60
+ };
61
+ const getTimings = ()=>{
62
+ const result = [];
63
+ timings.forEach((value, name)=>{
64
+ result.push({
65
+ name,
66
+ ...value,
67
+ avg: value.total / value.count
68
+ });
28
69
  });
29
70
  return result;
30
71
  };
31
72
  const printSummary = ()=>{
32
- if (!isDebug || timings.length === 0) {
73
+ if (!isDebug || timings.size === 0) {
33
74
  return;
34
75
  }
35
- const total = timings.reduce((sum, t)=>sum + t.duration, 0);
76
+ const entries = getTimings();
77
+ const total = entries.reduce((sum, t)=>sum + t.total, 0);
78
+ const displayPrefix = prefix ? `[${prefix}] ` : '';
36
79
  logger.debug('');
37
- logger.debug('⏱️ Build Performance Summary:');
38
- logger.debug('─'.repeat(60));
39
- timings.sort((a, b)=>b.duration - a.duration).forEach(({ name, duration })=>{
40
- const pct = (duration / total * 100).toFixed(1);
41
- const bar = ''.repeat(Math.round(duration / total * 20));
42
- logger.debug(`${name.padEnd(25)} ${duration.toFixed(2).padStart(10)}ms ${pct.padStart(6)}% ${bar}`);
80
+ logger.debug(`⏱️ ${displayPrefix}Build Performance Summary:`);
81
+ logger.debug('─'.repeat(90));
82
+ const header = [
83
+ 'Step'.padEnd(30),
84
+ 'Total'.padStart(10),
85
+ '%'.padStart(6),
86
+ 'Count'.padStart(7),
87
+ 'Avg'.padStart(10),
88
+ 'Min'.padStart(10),
89
+ 'Max'.padStart(10)
90
+ ].join(' ');
91
+ logger.debug(header);
92
+ logger.debug('─'.repeat(90));
93
+ entries.sort((a, b)=>b.total - a.total).forEach(({ name, total: stepTotal, count, avg, min, max })=>{
94
+ const pct = (stepTotal / total * 100).toFixed(1);
95
+ const displayName = name.length > 28 ? `${name.slice(0, 25)}...` : name;
96
+ const row = [
97
+ displayName.padEnd(30),
98
+ `${stepTotal.toFixed(2).padStart(8)}ms`,
99
+ `${pct.padStart(6)}%`,
100
+ String(count).padStart(7),
101
+ `${avg.toFixed(2).padStart(8)}ms`,
102
+ `${min.toFixed(2).padStart(8)}ms`,
103
+ `${max.toFixed(2).padStart(8)}ms`
104
+ ].join(' ');
105
+ logger.debug(row);
106
+ });
107
+ logger.debug('─'.repeat(90));
108
+ logger.debug(`${'TOTAL'.padEnd(30)} ${total.toFixed(2).padStart(8)}ms`);
109
+ };
110
+ const createSubProfiler = (subPrefix)=>{
111
+ return createBuildProfiler({
112
+ logger,
113
+ prefix: prefix ? `${prefix}::${subPrefix}` : subPrefix
43
114
  });
44
- logger.debug('─'.repeat(60));
45
- logger.debug(`${'TOTAL'.padEnd(25)} ${total.toFixed(2).padStart(10)}ms`);
46
115
  };
47
116
  return {
48
117
  time,
49
- printSummary
118
+ timeSync,
119
+ getTimings,
120
+ printSummary,
121
+ createSubProfiler,
122
+ isDebug
50
123
  };
51
124
  }
52
125
  export default createBuildProfiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "0.0.0-experimental-20251203181051",
3
+ "version": "0.0.0-experimental-20251203183323",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -44,14 +44,14 @@
44
44
  "dist/*"
45
45
  ],
46
46
  "dependencies": {
47
- "@lowdefy/ajv": "0.0.0-experimental-20251203181051",
48
- "@lowdefy/blocks-basic": "0.0.0-experimental-20251203181051",
49
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203181051",
50
- "@lowdefy/helpers": "0.0.0-experimental-20251203181051",
51
- "@lowdefy/node-utils": "0.0.0-experimental-20251203181051",
52
- "@lowdefy/nunjucks": "0.0.0-experimental-20251203181051",
53
- "@lowdefy/operators": "0.0.0-experimental-20251203181051",
54
- "@lowdefy/operators-js": "0.0.0-experimental-20251203181051",
47
+ "@lowdefy/ajv": "0.0.0-experimental-20251203183323",
48
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20251203183323",
49
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203183323",
50
+ "@lowdefy/helpers": "0.0.0-experimental-20251203183323",
51
+ "@lowdefy/node-utils": "0.0.0-experimental-20251203183323",
52
+ "@lowdefy/nunjucks": "0.0.0-experimental-20251203183323",
53
+ "@lowdefy/operators": "0.0.0-experimental-20251203183323",
54
+ "@lowdefy/operators-js": "0.0.0-experimental-20251203183323",
55
55
  "ajv": "8.12.0",
56
56
  "json5": "2.2.3",
57
57
  "yaml": "2.3.4",
@@ -59,35 +59,35 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@jest/globals": "28.1.3",
62
- "@lowdefy/actions-core": "0.0.0-experimental-20251203181051",
63
- "@lowdefy/actions-pdf-make": "0.0.0-experimental-20251203181051",
64
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20251203181051",
65
- "@lowdefy/blocks-algolia": "0.0.0-experimental-20251203181051",
66
- "@lowdefy/blocks-antd": "0.0.0-experimental-20251203181051",
67
- "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20251203181051",
68
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20251203181051",
69
- "@lowdefy/blocks-google-maps": "0.0.0-experimental-20251203181051",
70
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20251203181051",
71
- "@lowdefy/blocks-qr": "0.0.0-experimental-20251203181051",
72
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20251203181051",
73
- "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20251203181051",
74
- "@lowdefy/connection-google-sheets": "0.0.0-experimental-20251203181051",
75
- "@lowdefy/connection-knex": "0.0.0-experimental-20251203181051",
76
- "@lowdefy/connection-mongodb": "0.0.0-experimental-20251203181051",
77
- "@lowdefy/connection-redis": "0.0.0-experimental-20251203181051",
78
- "@lowdefy/connection-sendgrid": "0.0.0-experimental-20251203181051",
79
- "@lowdefy/connection-stripe": "0.0.0-experimental-20251203181051",
80
- "@lowdefy/operators-change-case": "0.0.0-experimental-20251203181051",
81
- "@lowdefy/operators-diff": "0.0.0-experimental-20251203181051",
82
- "@lowdefy/operators-moment": "0.0.0-experimental-20251203181051",
83
- "@lowdefy/operators-mql": "0.0.0-experimental-20251203181051",
84
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20251203181051",
85
- "@lowdefy/operators-uuid": "0.0.0-experimental-20251203181051",
86
- "@lowdefy/operators-yaml": "0.0.0-experimental-20251203181051",
87
- "@lowdefy/plugin-auth0": "0.0.0-experimental-20251203181051",
88
- "@lowdefy/plugin-aws": "0.0.0-experimental-20251203181051",
89
- "@lowdefy/plugin-csv": "0.0.0-experimental-20251203181051",
90
- "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203181051",
62
+ "@lowdefy/actions-core": "0.0.0-experimental-20251203183323",
63
+ "@lowdefy/actions-pdf-make": "0.0.0-experimental-20251203183323",
64
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20251203183323",
65
+ "@lowdefy/blocks-algolia": "0.0.0-experimental-20251203183323",
66
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20251203183323",
67
+ "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20251203183323",
68
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20251203183323",
69
+ "@lowdefy/blocks-google-maps": "0.0.0-experimental-20251203183323",
70
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20251203183323",
71
+ "@lowdefy/blocks-qr": "0.0.0-experimental-20251203183323",
72
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20251203183323",
73
+ "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20251203183323",
74
+ "@lowdefy/connection-google-sheets": "0.0.0-experimental-20251203183323",
75
+ "@lowdefy/connection-knex": "0.0.0-experimental-20251203183323",
76
+ "@lowdefy/connection-mongodb": "0.0.0-experimental-20251203183323",
77
+ "@lowdefy/connection-redis": "0.0.0-experimental-20251203183323",
78
+ "@lowdefy/connection-sendgrid": "0.0.0-experimental-20251203183323",
79
+ "@lowdefy/connection-stripe": "0.0.0-experimental-20251203183323",
80
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20251203183323",
81
+ "@lowdefy/operators-diff": "0.0.0-experimental-20251203183323",
82
+ "@lowdefy/operators-moment": "0.0.0-experimental-20251203183323",
83
+ "@lowdefy/operators-mql": "0.0.0-experimental-20251203183323",
84
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20251203183323",
85
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20251203183323",
86
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20251203183323",
87
+ "@lowdefy/plugin-auth0": "0.0.0-experimental-20251203183323",
88
+ "@lowdefy/plugin-aws": "0.0.0-experimental-20251203183323",
89
+ "@lowdefy/plugin-csv": "0.0.0-experimental-20251203183323",
90
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203183323",
91
91
  "@swc/cli": "0.1.63",
92
92
  "@swc/core": "1.3.99",
93
93
  "@swc/jest": "0.2.29",