@tramvai/cli 6.68.0 → 6.68.2
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/lib/api/benchmark/build.d.ts +1 -6
- package/lib/api/benchmark/build.d.ts.map +1 -1
- package/lib/api/benchmark/build.js +59 -23
- package/lib/api/benchmark/build.js.map +1 -1
- package/lib/api/benchmark/const.d.ts +2 -0
- package/lib/api/benchmark/const.d.ts.map +1 -0
- package/lib/api/benchmark/const.js +5 -0
- package/lib/api/benchmark/const.js.map +1 -0
- package/lib/api/benchmark/index.d.ts +4 -6
- package/lib/api/benchmark/index.d.ts.map +1 -1
- package/lib/api/benchmark/index.js.map +1 -1
- package/lib/api/benchmark/start.d.ts +1 -7
- package/lib/api/benchmark/start.d.ts.map +1 -1
- package/lib/api/benchmark/start.js +56 -49
- package/lib/api/benchmark/start.js.map +1 -1
- package/lib/api/benchmark/types.d.ts +76 -12
- package/lib/api/benchmark/types.d.ts.map +1 -1
- package/lib/api/benchmark/utils/compilationUtils.d.ts +4 -0
- package/lib/api/benchmark/utils/compilationUtils.d.ts.map +1 -0
- package/lib/api/benchmark/utils/compilationUtils.js +157 -0
- package/lib/api/benchmark/utils/compilationUtils.js.map +1 -0
- package/lib/api/benchmark/utils/stats.d.ts +2 -7
- package/lib/api/benchmark/utils/stats.d.ts.map +1 -1
- package/lib/api/benchmark/utils/stats.js +36 -22
- package/lib/api/benchmark/utils/stats.js.map +1 -1
- package/lib/api/build/index.d.ts +1 -0
- package/lib/api/build/index.d.ts.map +1 -1
- package/lib/api/build/index.js.map +1 -1
- package/lib/api/start/application.experimental.d.ts.map +1 -1
- package/lib/api/start/application.experimental.js +4 -3
- package/lib/api/start/application.experimental.js.map +1 -1
- package/lib/api/start/index.d.ts +1 -0
- package/lib/api/start/index.d.ts.map +1 -1
- package/lib/api/start/index.js.map +1 -1
- package/lib/builder/webpack/analyzePlugins/rsdoctor.d.ts +3 -3
- package/lib/builder/webpack/analyzePlugins/rsdoctor.d.ts.map +1 -1
- package/lib/builder/webpack/analyzePlugins/rsdoctor.js +1 -11
- package/lib/builder/webpack/analyzePlugins/rsdoctor.js.map +1 -1
- package/lib/builder/webpack/providers/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/shared.js +10 -7
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/commands/benchmark/benchmark.d.ts +3 -1
- package/lib/commands/benchmark/benchmark.d.ts.map +1 -1
- package/lib/commands/benchmark/benchmark.js +130 -31
- package/lib/commands/benchmark/benchmark.js.map +1 -1
- package/lib/commands/benchmark/command.d.ts +9 -0
- package/lib/commands/benchmark/command.d.ts.map +1 -1
- package/lib/commands/benchmark/command.js +18 -0
- package/lib/commands/benchmark/command.js.map +1 -1
- package/lib/config/configManager.d.ts +1 -0
- package/lib/config/configManager.d.ts.map +1 -1
- package/lib/config/configManager.js +1 -0
- package/lib/config/configManager.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts.map +1 -1
- package/lib/library/webpack/common/main.js +7 -0
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/utils/threadLoader.d.ts.map +1 -1
- package/lib/library/webpack/utils/threadLoader.js +2 -1
- package/lib/library/webpack/utils/threadLoader.js.map +1 -1
- package/lib/typings/build/Builder.d.ts +3 -2
- package/lib/typings/build/Builder.d.ts.map +1 -1
- package/package.json +9 -10
- package/src/api/benchmark/__integration__/start.test.ts +10 -12
- package/src/api/benchmark/build.ts +75 -30
- package/src/api/benchmark/const.ts +1 -0
- package/src/api/benchmark/index.ts +4 -6
- package/src/api/benchmark/start.ts +69 -65
- package/src/api/benchmark/types.ts +82 -14
- package/src/api/benchmark/utils/compilationUtils.ts +213 -0
- package/src/api/benchmark/utils/stats.ts +45 -28
- package/src/api/build/index.ts +1 -0
- package/src/api/start/application.experimental.ts +4 -3
- package/src/api/start/index.ts +1 -0
- package/src/builder/webpack/analyzePlugins/rsdoctor.ts +2 -14
- package/src/builder/webpack/providers/shared.ts +7 -4
- package/src/commands/benchmark/benchmark.ts +168 -33
- package/src/commands/benchmark/command.ts +19 -0
- package/src/config/configManager.ts +2 -0
- package/src/library/webpack/common/main.ts +8 -0
- package/src/library/webpack/utils/threadLoader.ts +1 -0
- package/src/typings/build/Builder.ts +4 -2
- package/lib/builder/webpack/utils/calculateBuildTime.d.ts +0 -3
- package/lib/builder/webpack/utils/calculateBuildTime.d.ts.map +0 -1
- package/lib/builder/webpack/utils/calculateBuildTime.js +0 -18
- package/lib/builder/webpack/utils/calculateBuildTime.js.map +0 -1
- package/lib/builder/webpack/utils/maxMemoryRss.d.ts +0 -2
- package/lib/builder/webpack/utils/maxMemoryRss.d.ts.map +0 -1
- package/lib/builder/webpack/utils/maxMemoryRss.js +0 -15
- package/lib/builder/webpack/utils/maxMemoryRss.js.map +0 -1
- package/src/api/benchmark/utils/stats.spec.ts +0 -36
- package/src/builder/webpack/utils/calculateBuildTime.ts +0 -17
- package/src/builder/webpack/utils/maxMemoryRss.ts +0 -12
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
+
import { calculateBuildTime, maxMemoryRss } from '@tramvai/plugin-webpack-builder';
|
|
4
5
|
import { CONFIG_MANAGER_TOKEN, WITH_BUILD_STATS_TOKEN } from '../../../di/tokens';
|
|
5
6
|
import { closeWorkerPool, warmupWorkerPool } from '../../../library/webpack/utils/threadLoader';
|
|
6
7
|
import {
|
|
@@ -11,9 +12,7 @@ import {
|
|
|
11
12
|
WEBPACK_CLIENT_COMPILER_TOKEN,
|
|
12
13
|
WEBPACK_SERVER_COMPILER_TOKEN,
|
|
13
14
|
} from '../tokens';
|
|
14
|
-
import { calculateBuildTime } from '../utils/calculateBuildTime';
|
|
15
15
|
import { emitWebpackEvents } from '../utils/webpackEvents';
|
|
16
|
-
import { maxMemoryRss } from '../utils/maxMemoryRss';
|
|
17
16
|
|
|
18
17
|
export const sharedProviders: Provider[] = [
|
|
19
18
|
provide({
|
|
@@ -31,8 +30,12 @@ export const sharedProviders: Provider[] = [
|
|
|
31
30
|
const getMaxMemoryRss = maxMemoryRss();
|
|
32
31
|
return () => {
|
|
33
32
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
client: {
|
|
34
|
+
buildTime: getClientTime?.(),
|
|
35
|
+
},
|
|
36
|
+
server: {
|
|
37
|
+
buildTime: getServerTime?.(),
|
|
38
|
+
},
|
|
36
39
|
maxMemoryRss: getMaxMemoryRss?.(),
|
|
37
40
|
};
|
|
38
41
|
};
|
|
@@ -1,59 +1,194 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { table, TableUserConfig } from 'table';
|
|
2
|
+
import isEmpty from '@tinkoff/utils/is/empty';
|
|
3
|
+
|
|
3
4
|
import type { Context } from '../../models/context';
|
|
4
5
|
import type { CommandResult } from '../../models/command';
|
|
5
6
|
import type { Result } from '../../api/benchmark';
|
|
7
|
+
import type { CompilationStats } from '../../api/benchmark/types';
|
|
8
|
+
import { DEFAULT_TIMES } from '../../api/benchmark/const';
|
|
6
9
|
|
|
7
10
|
import { app } from '../index';
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
export function toFixedDigits(num: number, digits = 2): number {
|
|
13
|
+
if (digits === 0) {
|
|
14
|
+
return Math.floor(num);
|
|
15
|
+
}
|
|
16
|
+
return +num.toFixed(digits);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const getUnit = (num: number) => (num > 1 ? 'mins' : 'min');
|
|
20
|
+
|
|
21
|
+
export function formatCosts(costs: number): string {
|
|
22
|
+
// more than 1s
|
|
23
|
+
if (costs >= 1000) {
|
|
24
|
+
const sec = costs / 1000;
|
|
25
|
+
// more than 1min
|
|
26
|
+
if (sec >= 60) {
|
|
27
|
+
let mins = sec / 60;
|
|
28
|
+
|
|
29
|
+
mins = toFixedDigits(mins, 0);
|
|
30
|
+
const mUnit = getUnit(mins);
|
|
31
|
+
const restSec = toFixedDigits(sec % 60, 0);
|
|
32
|
+
|
|
33
|
+
if (restSec > 0) {
|
|
34
|
+
return `${mins}${mUnit} ${restSec}s`;
|
|
35
|
+
}
|
|
36
|
+
return `${mins}${mUnit}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${toFixedDigits(sec, 1)}s`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (costs >= 10) {
|
|
43
|
+
return `${+toFixedDigits(costs, 0)}ms`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (costs >= 1) {
|
|
47
|
+
return `${+toFixedDigits(costs, 1)}ms`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let r = +toFixedDigits(costs, 2);
|
|
51
|
+
|
|
52
|
+
if (r === 0) {
|
|
53
|
+
r = +toFixedDigits(costs, 3);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return `${r}ms`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const formatValues = (measures: Record<string, number>) => {
|
|
60
|
+
const result: [string, string][] = [];
|
|
61
|
+
|
|
62
|
+
for (const measureName in measures) {
|
|
63
|
+
const measureValue = measures[measureName];
|
|
64
|
+
result.push([measureName, formatCosts(measureValue)]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const filterStats = (measures: Record<string, number>) => {
|
|
71
|
+
const entries = Object.entries(measures);
|
|
72
|
+
entries.sort((a, b) => b[1] - a[1]);
|
|
10
73
|
|
|
11
|
-
|
|
12
|
-
|
|
74
|
+
return entries.slice(0, 5).reduce((acc, [key, value]) => {
|
|
75
|
+
acc[key] = value;
|
|
76
|
+
return acc;
|
|
77
|
+
}, {});
|
|
13
78
|
};
|
|
14
79
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
80
|
+
const getInfo = (compilationStats: CompilationStats) => {
|
|
81
|
+
const { totalBuildCosts, loaderBuildCosts, pluginBuildCosts } = compilationStats;
|
|
82
|
+
|
|
83
|
+
const totalBuildInfo = formatValues(totalBuildCosts);
|
|
84
|
+
const loaderInfo = formatValues(filterStats(loaderBuildCosts));
|
|
85
|
+
const pluginInfo = formatValues(filterStats(pluginBuildCosts));
|
|
19
86
|
|
|
20
|
-
return
|
|
87
|
+
return { totalBuildInfo, loaderInfo, pluginInfo };
|
|
21
88
|
};
|
|
22
89
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
90
|
+
const mergeTotalInfo = (
|
|
91
|
+
server?: [string, string][] | undefined,
|
|
92
|
+
client?: [string, string][] | undefined
|
|
93
|
+
) => {
|
|
94
|
+
const result = [];
|
|
27
95
|
|
|
28
|
-
for (
|
|
29
|
-
|
|
30
|
-
|
|
96
|
+
for (let i = 0; i < (server?.length ?? client?.length); i++) {
|
|
97
|
+
result.push([
|
|
98
|
+
server?.[i][0] ?? client?.[i][0] ?? '-',
|
|
99
|
+
server?.[i][1] ?? '0',
|
|
100
|
+
client?.[i][1] ?? '0',
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
31
106
|
|
|
32
|
-
|
|
107
|
+
const mergeAdditionalInfo = (
|
|
108
|
+
server?: [string, string][] | undefined,
|
|
109
|
+
client?: [string, string][] | undefined
|
|
110
|
+
) => {
|
|
111
|
+
const result = [];
|
|
33
112
|
|
|
34
|
-
|
|
35
|
-
|
|
113
|
+
for (let i = 0; i < (server?.length ?? client?.length); i++) {
|
|
114
|
+
result.push([
|
|
115
|
+
server?.[i][0] ?? '-',
|
|
116
|
+
server?.[i][1] ?? '0',
|
|
117
|
+
client?.[i][0] ?? '-',
|
|
118
|
+
client?.[i][1] ?? 0,
|
|
119
|
+
]);
|
|
36
120
|
}
|
|
37
121
|
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
122
|
+
return result;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const formatBuildTime = (totalBuildTime) =>
|
|
126
|
+
totalBuildTime ? `${(totalBuildTime / 1000).toFixed(2)}s` : '-';
|
|
127
|
+
|
|
128
|
+
const formatMemoryRss = (memoryRss) => (memoryRss ? `${(memoryRss / 1000000).toFixed(2)}mb` : '-');
|
|
129
|
+
|
|
130
|
+
const formatStatsTables = (stats: Result, times: number | undefined = DEFAULT_TIMES) => {
|
|
131
|
+
const {
|
|
132
|
+
clientBuildTime,
|
|
133
|
+
clientCompilationStats,
|
|
134
|
+
serverBuildTime,
|
|
135
|
+
serverCompilationStats,
|
|
136
|
+
maxMemoryRss,
|
|
137
|
+
clientMaxMemoryRss,
|
|
138
|
+
serverMaxMemoryRss,
|
|
139
|
+
} = stats;
|
|
140
|
+
const serverInfo = !isEmpty(serverCompilationStats) && getInfo(serverCompilationStats);
|
|
141
|
+
const clientInfo = !isEmpty(clientCompilationStats) && getInfo(clientCompilationStats);
|
|
142
|
+
|
|
143
|
+
const totalBuildData = [
|
|
144
|
+
[`Mean durations (${times} times)`, 'server', 'client'],
|
|
145
|
+
['Total build time', formatBuildTime(serverBuildTime), formatBuildTime(clientBuildTime)],
|
|
146
|
+
maxMemoryRss
|
|
147
|
+
? ['Total memory', formatMemoryRss(maxMemoryRss), '']
|
|
148
|
+
: ['Total memory', formatMemoryRss(serverMaxMemoryRss), formatMemoryRss(clientMaxMemoryRss)],
|
|
149
|
+
...mergeTotalInfo(serverInfo.totalBuildInfo, clientInfo.totalBuildInfo),
|
|
150
|
+
].filter(Boolean);
|
|
151
|
+
|
|
152
|
+
const totalBuildTableConfig: TableUserConfig = {
|
|
153
|
+
columns: [{ alignment: 'left' }, { alignment: 'center' }, { alignment: 'center' }],
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (maxMemoryRss) {
|
|
157
|
+
// @ts-expect-error
|
|
158
|
+
totalBuildTableConfig.spanningCells = [{ col: 1, row: 2, colSpan: 2, alignment: 'center' }];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const mergedLoadersInfo = mergeAdditionalInfo(serverInfo.loaderInfo, clientInfo.loaderInfo);
|
|
162
|
+
const mergedPluginsInfo = mergeAdditionalInfo(serverInfo.pluginInfo, clientInfo.pluginInfo);
|
|
163
|
+
const additionalBuildData = [
|
|
164
|
+
['server', '', 'client', ''],
|
|
165
|
+
['Loaders', '', '', ''],
|
|
166
|
+
...mergedLoadersInfo,
|
|
167
|
+
['Plugins', '', '', ''],
|
|
168
|
+
...mergedPluginsInfo,
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const additionalBuildTableConfig: TableUserConfig = {
|
|
172
|
+
spanningCells: [
|
|
173
|
+
{ col: 0, row: 0, colSpan: 2, alignment: 'center' },
|
|
174
|
+
{ col: 2, row: 0, colSpan: 2, alignment: 'center' },
|
|
175
|
+
{ col: 0, row: 1, colSpan: 4, alignment: 'center' },
|
|
176
|
+
{ col: 0, row: mergedLoadersInfo.length + 2, colSpan: 4, alignment: 'center' },
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return [
|
|
181
|
+
table(totalBuildData, totalBuildTableConfig),
|
|
182
|
+
table(additionalBuildData, additionalBuildTableConfig),
|
|
183
|
+
];
|
|
49
184
|
};
|
|
50
185
|
|
|
51
|
-
export default async (
|
|
186
|
+
export default async (_context: Context, parameters): Promise<CommandResult | any> => {
|
|
52
187
|
const { command, times, ...commandOptions } = parameters;
|
|
53
188
|
|
|
54
189
|
const stats = await app.run('benchmark', { command, times, commandOptions });
|
|
55
190
|
|
|
56
|
-
console.log(
|
|
191
|
+
formatStatsTables(stats, times).forEach((buildTable) => console.log(buildTable));
|
|
57
192
|
|
|
58
193
|
return Promise.resolve({
|
|
59
194
|
status: 'ok',
|
|
@@ -32,11 +32,30 @@ export class BenchmarkCommand extends CLICommand<Params> {
|
|
|
32
32
|
description:
|
|
33
33
|
'Specify the names of the bundles that need to be collected, other bundles will not be collected and their request will fail with an error',
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
name: '--fileCache',
|
|
37
|
+
value: '[fileCache]',
|
|
38
|
+
transformer: (value: string) => value !== 'false',
|
|
39
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: '-t, --buildType',
|
|
43
|
+
value: '[type]',
|
|
44
|
+
description: 'Build type <client|server>',
|
|
45
|
+
defaultValue: 'client',
|
|
46
|
+
},
|
|
35
47
|
{
|
|
36
48
|
name: '--times',
|
|
37
49
|
value: '[times]',
|
|
38
50
|
description: 'How many times to run single type of benchmark',
|
|
39
51
|
},
|
|
52
|
+
{
|
|
53
|
+
name: '--experimentalWebpackWorkerThreads',
|
|
54
|
+
value: '[experimentalWebpackWorkerThreads]',
|
|
55
|
+
transformer: (value: string) => value !== 'false',
|
|
56
|
+
description:
|
|
57
|
+
'Enable new experimental @tramvai/api builder to run webpack compilation in worker threads',
|
|
58
|
+
},
|
|
40
59
|
];
|
|
41
60
|
|
|
42
61
|
alias = 'bench';
|
|
@@ -37,6 +37,7 @@ export interface Settings<E extends Env> {
|
|
|
37
37
|
profile?: boolean;
|
|
38
38
|
noServerRebuild?: boolean;
|
|
39
39
|
noClientRebuild?: boolean;
|
|
40
|
+
benchmark?: boolean;
|
|
40
41
|
resolveSymlinks?: boolean;
|
|
41
42
|
showConfig?: boolean;
|
|
42
43
|
onlyBundles?: string[];
|
|
@@ -131,6 +132,7 @@ export const createConfigManager = <C extends ConfigEntry = ConfigEntry, E exten
|
|
|
131
132
|
profile: false,
|
|
132
133
|
noClientRebuild: false,
|
|
133
134
|
noServerRebuild: false,
|
|
135
|
+
benchmark: false,
|
|
134
136
|
resolveSymlinks: true,
|
|
135
137
|
disableProdOptimization: false,
|
|
136
138
|
onlyBundles: [],
|
|
@@ -3,6 +3,8 @@ import type Config from 'webpack-chain';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { existsSync } from 'fs-extra';
|
|
5
5
|
import findCacheDir from 'find-cache-dir';
|
|
6
|
+
import { RsdoctorWebpackMultiplePlugin } from '@rsdoctor/webpack-plugin';
|
|
7
|
+
import { getRsdoctorOptions } from '@tramvai/plugin-webpack-builder';
|
|
6
8
|
import { ignoreWarnings } from '../utils/warningsFilter';
|
|
7
9
|
import resolve from '../blocks/resolve';
|
|
8
10
|
import ignoreLocales from '../blocks/ignoreLocales';
|
|
@@ -126,6 +128,12 @@ export default (configManager: ConfigManager<CliConfigEntry>) => (config: Config
|
|
|
126
128
|
},
|
|
127
129
|
]);
|
|
128
130
|
|
|
131
|
+
if (configManager.benchmark) {
|
|
132
|
+
config
|
|
133
|
+
.plugin('rsdoctor-benchmark')
|
|
134
|
+
.use(RsdoctorWebpackMultiplePlugin, [getRsdoctorOptions(configManager.buildType)]);
|
|
135
|
+
}
|
|
136
|
+
|
|
129
137
|
// TODO: remove after dropping support for node@14
|
|
130
138
|
if (configManager.buildType === 'server') {
|
|
131
139
|
config.plugin('node-performance').use(webpack.ProvidePlugin, [
|
|
@@ -43,6 +43,7 @@ const createWorkerPoolConfig = (configManager: ConfigManager<CliConfigEntry>) =>
|
|
|
43
43
|
|
|
44
44
|
const isApplicable = (configManager: ConfigManager<CliConfigEntry>) => {
|
|
45
45
|
return (
|
|
46
|
+
!configManager.benchmark &&
|
|
46
47
|
process.env.TRAMVAI_DISABLE_THREAD_LOADER !== 'true' &&
|
|
47
48
|
// thread-loader uses child_process.fork under the hood, and sometimes (50/50) work in these processes does not get into inspector.Session profile
|
|
48
49
|
!process.env.TRAMVAI_CPU_PROFILE &&
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BuildStats } from '@tramvai/api/lib/builder/dev-server';
|
|
2
|
+
|
|
1
3
|
export interface BuilderCustomOptions {
|
|
2
4
|
[key: string]: Record<string, any>;
|
|
3
5
|
}
|
|
@@ -35,8 +37,8 @@ interface BuilderAnalyzeOptions {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export type GetBuildStats = () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
client?: BuildStats;
|
|
41
|
+
server?: BuildStats;
|
|
40
42
|
maxMemoryRss?: number;
|
|
41
43
|
};
|
|
42
44
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calculateBuildTime.d.ts","sourceRoot":"","sources":["../../../../src/builder/webpack/utils/calculateBuildTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,kBAAkB,aAAc,QAAQ,iBAcpD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateBuildTime = void 0;
|
|
4
|
-
const calculateBuildTime = (compiler) => {
|
|
5
|
-
let startTime = Date.now();
|
|
6
|
-
let timeDiff;
|
|
7
|
-
compiler.hooks.invalid.tap('calculateBuildTime', () => {
|
|
8
|
-
startTime = Date.now();
|
|
9
|
-
});
|
|
10
|
-
compiler.hooks.done.tap('calculateBuildTime', (stats) => {
|
|
11
|
-
timeDiff = Date.now() - startTime;
|
|
12
|
-
});
|
|
13
|
-
return () => {
|
|
14
|
-
return timeDiff;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
exports.calculateBuildTime = calculateBuildTime;
|
|
18
|
-
//# sourceMappingURL=calculateBuildTime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calculateBuildTime.js","sourceRoot":"","sources":["../../../../src/builder/webpack/utils/calculateBuildTime.ts"],"names":[],"mappings":";;;AAEO,MAAM,kBAAkB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACvD,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,QAAgB,CAAC;IAErB,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,EAAE;QACpD,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;QACtD,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,kBAAkB,sBAc7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maxMemoryRss.d.ts","sourceRoot":"","sources":["../../../../src/builder/webpack/utils/maxMemoryRss.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,oBAWxB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxMemoryRss = void 0;
|
|
4
|
-
const maxMemoryRss = () => {
|
|
5
|
-
let maxMemory = process.memoryUsage.rss();
|
|
6
|
-
const interval = setInterval(() => {
|
|
7
|
-
maxMemory = Math.max(maxMemory, process.memoryUsage.rss());
|
|
8
|
-
}, 5000);
|
|
9
|
-
return () => {
|
|
10
|
-
clearInterval(interval);
|
|
11
|
-
return maxMemory;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.maxMemoryRss = maxMemoryRss;
|
|
15
|
-
//# sourceMappingURL=maxMemoryRss.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maxMemoryRss.js","sourceRoot":"","sources":["../../../../src/builder/webpack/utils/maxMemoryRss.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;IAE1C,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7D,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,OAAO,GAAG,EAAE;QACV,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getSamplesStats } from './stats';
|
|
2
|
-
|
|
3
|
-
describe('getSamplesStats', () => {
|
|
4
|
-
it('base case', () => {
|
|
5
|
-
const samples = [1, 1, 1, 1, 1];
|
|
6
|
-
|
|
7
|
-
expect(getSamplesStats(samples)).toEqual({
|
|
8
|
-
samples,
|
|
9
|
-
mean: 1,
|
|
10
|
-
std: 0,
|
|
11
|
-
variance: 0,
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('case 1', () => {
|
|
16
|
-
const samples = [1, 2, 3, 4, 5, 6, 7];
|
|
17
|
-
|
|
18
|
-
expect(getSamplesStats(samples)).toEqual({
|
|
19
|
-
samples,
|
|
20
|
-
mean: 4,
|
|
21
|
-
std: 2,
|
|
22
|
-
variance: 50,
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('case 2', () => {
|
|
27
|
-
const samples = [100, 105, 103, 95, 102, 109, 98];
|
|
28
|
-
|
|
29
|
-
expect(getSamplesStats(samples)).toEqual({
|
|
30
|
-
samples,
|
|
31
|
-
mean: 101.71428571428571,
|
|
32
|
-
std: 4.266624149448022,
|
|
33
|
-
variance: 4.194714753670809,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack';
|
|
2
|
-
|
|
3
|
-
export const calculateBuildTime = (compiler: Compiler) => {
|
|
4
|
-
let startTime = Date.now();
|
|
5
|
-
let timeDiff: number;
|
|
6
|
-
|
|
7
|
-
compiler.hooks.invalid.tap('calculateBuildTime', () => {
|
|
8
|
-
startTime = Date.now();
|
|
9
|
-
});
|
|
10
|
-
compiler.hooks.done.tap('calculateBuildTime', (stats) => {
|
|
11
|
-
timeDiff = Date.now() - startTime;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
return () => {
|
|
15
|
-
return timeDiff;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const maxMemoryRss = () => {
|
|
2
|
-
let maxMemory = process.memoryUsage.rss();
|
|
3
|
-
|
|
4
|
-
const interval = setInterval(() => {
|
|
5
|
-
maxMemory = Math.max(maxMemory, process.memoryUsage.rss());
|
|
6
|
-
}, 5000);
|
|
7
|
-
|
|
8
|
-
return () => {
|
|
9
|
-
clearInterval(interval);
|
|
10
|
-
return maxMemory;
|
|
11
|
-
};
|
|
12
|
-
};
|