@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,14 +1,9 @@
|
|
|
1
1
|
import type { Container } from '@tinkoff/dippy';
|
|
2
2
|
import type { Params as OriginalBuildParams } from '../build/index';
|
|
3
3
|
import type { Params, Result } from './index';
|
|
4
|
-
import type { RunStats } from './types';
|
|
5
4
|
export interface BuildParams extends Params {
|
|
6
5
|
command: 'build';
|
|
7
6
|
commandOptions: OriginalBuildParams;
|
|
8
7
|
}
|
|
9
|
-
export
|
|
10
|
-
noCache?: RunStats;
|
|
11
|
-
cache?: RunStats;
|
|
12
|
-
}
|
|
13
|
-
export declare const benchmarkBuild: (di: Container) => Promise<BuildResult>;
|
|
8
|
+
export declare const benchmarkBuild: (di: Container) => Promise<Result>;
|
|
14
9
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,mBAAmB,EAAiC,MAAM,gBAAgB,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAO9C,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,mBAAmB,CAAC;CACrC;AAoFD,eAAO,MAAM,cAAc,OAAc,SAAS,KAAG,QAAQ,MAAM,CAoBlE,CAAC"}
|
|
@@ -4,43 +4,79 @@ exports.benchmarkBuild = void 0;
|
|
|
4
4
|
const tokens_1 = require("../../di/tokens");
|
|
5
5
|
const clearCache_1 = require("./utils/clearCache");
|
|
6
6
|
const stats_1 = require("./utils/stats");
|
|
7
|
+
const compilationUtils_1 = require("./utils/compilationUtils");
|
|
8
|
+
const const_1 = require("./const");
|
|
7
9
|
const runBuildCommand = async (di, { times, shouldClearCache, }) => {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const clientBuildTimeSamples = [];
|
|
11
|
+
const serverBuildTimeSamples = [];
|
|
12
|
+
const clientMaxMemoryRssSamples = [];
|
|
13
|
+
const serverMaxMemoryRssSamples = [];
|
|
14
|
+
const serverCompilationTimings = [];
|
|
15
|
+
const clientCompilationTimings = [];
|
|
16
|
+
const maxMemoryRssSamples = [];
|
|
11
17
|
const { commandOptions } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
18
|
+
commandOptions.benchmark = true;
|
|
19
|
+
const buildType = commandOptions.buildType ?? 'all';
|
|
20
|
+
const benchmarkStartTime = new Date().toISOString();
|
|
12
21
|
for (let i = 0; i < times; i++) {
|
|
13
22
|
if (shouldClearCache) {
|
|
14
23
|
await (0, clearCache_1.clearCacheDirectory)(di);
|
|
15
24
|
}
|
|
16
|
-
const
|
|
25
|
+
const attemptStartTime = Date.now();
|
|
26
|
+
const { getBuildStats } = await di
|
|
17
27
|
.get(tokens_1.COMMAND_RUNNER_TOKEN)
|
|
18
28
|
.run('build', commandOptions);
|
|
19
|
-
const stats =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
const stats = getBuildStats();
|
|
30
|
+
// at first attempt do not save metrics if cache is used
|
|
31
|
+
if (!shouldClearCache && i === 0) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (buildType === 'all' || buildType === 'server') {
|
|
35
|
+
serverCompilationTimings.push(await (0, compilationUtils_1.getServerCompilationTimings)(benchmarkStartTime, attemptStartTime, i));
|
|
36
|
+
serverBuildTimeSamples.push(stats.server.buildTime);
|
|
37
|
+
if (stats.server.maxMemoryRss) {
|
|
38
|
+
clientMaxMemoryRssSamples.push(stats.server.maxMemoryRss);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (buildType === 'all' || buildType === 'client') {
|
|
42
|
+
clientCompilationTimings.push(await (0, compilationUtils_1.getClientCompilationTimings)(benchmarkStartTime, attemptStartTime, i));
|
|
43
|
+
clientBuildTimeSamples.push(stats.client.buildTime);
|
|
44
|
+
if (stats.client.maxMemoryRss) {
|
|
45
|
+
clientMaxMemoryRssSamples.push(stats.client.maxMemoryRss);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (stats.maxMemoryRss) {
|
|
49
|
+
maxMemoryRssSamples.push(stats.maxMemoryRss);
|
|
50
|
+
}
|
|
23
51
|
}
|
|
24
52
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
53
|
+
serverCompilationTimings,
|
|
54
|
+
clientCompilationTimings,
|
|
55
|
+
clientBuildTimeSamples,
|
|
56
|
+
serverBuildTimeSamples,
|
|
27
57
|
maxMemoryRssSamples,
|
|
58
|
+
clientMaxMemoryRssSamples,
|
|
59
|
+
serverMaxMemoryRssSamples,
|
|
28
60
|
};
|
|
29
61
|
};
|
|
30
62
|
const benchmarkBuild = async (di) => {
|
|
31
|
-
const { times =
|
|
32
|
-
const noCache =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
const { times = const_1.DEFAULT_TIMES, commandOptions } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
64
|
+
const noCache = !commandOptions.fileCache;
|
|
65
|
+
let result;
|
|
66
|
+
if (noCache) {
|
|
67
|
+
result = await runBuildCommand(di, {
|
|
68
|
+
times,
|
|
69
|
+
shouldClearCache: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
result = await runBuildCommand(di, {
|
|
74
|
+
// additional first attempt for cache warmup
|
|
75
|
+
times: times + 1,
|
|
76
|
+
shouldClearCache: false,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return (0, stats_1.getResultStats)(result);
|
|
44
80
|
};
|
|
45
81
|
exports.benchmarkBuild = benchmarkBuild;
|
|
46
82
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/api/benchmark/build.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/api/benchmark/build.ts"],"names":[],"mappings":";;;AAGA,4CAAiF;AAGjF,mDAAyD;AACzD,yCAA+C;AAC/C,+DAAoG;AACpG,mCAAwC;AAOxC,MAAM,eAAe,GAAG,KAAK,EAC3B,EAAa,EACb,EACE,KAAK,EACL,gBAAgB,GAIjB,EACiB,EAAE;IACpB,MAAM,sBAAsB,GAAa,EAAE,CAAC;IAC5C,MAAM,sBAAsB,GAAa,EAAE,CAAC;IAE5C,MAAM,yBAAyB,GAAa,EAAE,CAAC;IAC/C,MAAM,yBAAyB,GA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AAM,CAAC,CAAC;AAChC,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/api/benchmark/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,CAAC,CAAC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
-
import type { BuildParams
|
|
3
|
-
import type { StartParams
|
|
2
|
+
import type { BuildParams } from './build';
|
|
3
|
+
import type { StartParams } from './start';
|
|
4
4
|
import type { RunStats } from './types';
|
|
5
5
|
export interface Params {
|
|
6
6
|
command: string;
|
|
7
7
|
commandOptions: any;
|
|
8
8
|
times?: number;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export type BenchmarkCommand = (params: StartParams | BuildParams, providers?: Provider[]) => Promise<StartResult | BuildResult>;
|
|
10
|
+
export type Result = RunStats;
|
|
11
|
+
export type BenchmarkCommand = (params: StartParams | BuildParams, providers?: Provider[]) => Promise<Result>;
|
|
14
12
|
declare const _default: import("../../typings/commands").Command;
|
|
15
13
|
export default _default;
|
|
16
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,GAAG,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE9B,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,WAAW,GAAG,WAAW,EACjC,SAAS,CAAC,EAAE,QAAQ,EAAE,KACnB,OAAO,CAAC,MAAM,CAAC,CAAC;;AAErB,wBAkBG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/benchmark/index.ts"],"names":[],"mappings":";;AACA,gEAA6D;AAC7D,4CAAmF;AAEnF,mCAAyC;AAEzC,mCAAyC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/benchmark/index.ts"],"names":[],"mappings":";;AACA,gEAA6D;AAC7D,4CAAmF;AAEnF,mCAAyC;AAEzC,mCAAyC;AAgBzC,kBAAe,IAAA,6BAAa,EAAC;IAC3B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,CAAC,EAAE,EAAmB,EAAE;QAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,iCAAwB,CAAW,CAAC;QAE/D,QAAQ,OAAO,EAAE;YACf,KAAK,OAAO;gBACV,OAAO,IAAA,sBAAc,EAAC,EAAE,CAAC,CAAC;YAC5B,KAAK,OAAO;gBACV,OAAO,IAAA,sBAAc,EAAC,EAAE,CAAC,CAAC;SAC7B;IACH,CAAC;IACD,SAAS,EAAE;QACT;YACE,OAAO,EAAE,+BAAsB;YAC/B,QAAQ,EAAE,IAAI;SACf;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import type { Container } from '@tinkoff/dippy';
|
|
2
2
|
import type { Params as OriginalStartParams } from '../start/index';
|
|
3
3
|
import type { Params, Result } from './index';
|
|
4
|
-
import type { RunStats } from './types';
|
|
5
4
|
export interface StartParams extends Params {
|
|
6
5
|
command: 'start';
|
|
7
6
|
commandOptions: OriginalStartParams;
|
|
8
7
|
}
|
|
9
|
-
export
|
|
10
|
-
noCache?: RunStats;
|
|
11
|
-
cache?: RunStats;
|
|
12
|
-
rebuild?: RunStats;
|
|
13
|
-
}
|
|
14
|
-
export declare const benchmarkStart: (di: Container) => Promise<StartResult>;
|
|
8
|
+
export declare const benchmarkStart: (di: Container) => Promise<Result>;
|
|
15
9
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/start.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,mBAAmB,EAAiC,MAAM,gBAAgB,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAO9C,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,mBAAmB,CAAC;CACrC;AAqFD,eAAO,MAAM,cAAc,OAAc,SAAS,KAAG,QAAQ,MAAM,CAoBlE,CAAC"}
|
|
@@ -4,73 +4,80 @@ exports.benchmarkStart = void 0;
|
|
|
4
4
|
const tokens_1 = require("../../di/tokens");
|
|
5
5
|
const clearCache_1 = require("./utils/clearCache");
|
|
6
6
|
const stats_1 = require("./utils/stats");
|
|
7
|
-
const
|
|
7
|
+
const compilationUtils_1 = require("./utils/compilationUtils");
|
|
8
|
+
const const_1 = require("./const");
|
|
8
9
|
const runStartCommand = async (di, { times, shouldClearCache, }) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const clientBuildTimeSamples = [];
|
|
11
|
+
const serverBuildTimeSamples = [];
|
|
12
|
+
const clientMaxMemoryRssSamples = [];
|
|
13
|
+
const serverMaxMemoryRssSamples = [];
|
|
14
|
+
const serverCompilationTimings = [];
|
|
15
|
+
const clientCompilationTimings = [];
|
|
16
|
+
const maxMemoryRssSamples = [];
|
|
12
17
|
const { commandOptions } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
18
|
+
commandOptions.benchmark = true;
|
|
19
|
+
const buildType = commandOptions.buildType ?? 'all';
|
|
20
|
+
const benchmarkStartTime = new Date().toISOString();
|
|
13
21
|
for (let i = 0; i < times; i++) {
|
|
14
22
|
if (shouldClearCache) {
|
|
15
23
|
await (0, clearCache_1.clearCacheDirectory)(di);
|
|
16
24
|
}
|
|
25
|
+
const attemptStartTime = Date.now();
|
|
17
26
|
const { close, getBuildStats } = await di
|
|
18
27
|
.get(tokens_1.COMMAND_RUNNER_TOKEN)
|
|
19
28
|
.run('start', commandOptions);
|
|
20
29
|
const stats = getBuildStats();
|
|
21
30
|
await close();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
// at first attempt do not save metrics if cache is used
|
|
32
|
+
if (!shouldClearCache && i === 0) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (buildType === 'all' || buildType === 'server') {
|
|
36
|
+
serverCompilationTimings.push(await (0, compilationUtils_1.getServerCompilationTimings)(benchmarkStartTime, attemptStartTime, i));
|
|
37
|
+
serverBuildTimeSamples.push(stats.server.buildTime);
|
|
38
|
+
if (stats.server.maxMemoryRss) {
|
|
39
|
+
serverMaxMemoryRssSamples.push(stats.server.maxMemoryRss);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (buildType === 'all' || buildType === 'client') {
|
|
43
|
+
clientCompilationTimings.push(await (0, compilationUtils_1.getClientCompilationTimings)(benchmarkStartTime, attemptStartTime, i));
|
|
44
|
+
clientBuildTimeSamples.push(stats.client.buildTime);
|
|
45
|
+
if (stats.client.maxMemoryRss) {
|
|
46
|
+
clientMaxMemoryRssSamples.push(stats.client.maxMemoryRss);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (stats.maxMemoryRss) {
|
|
50
|
+
maxMemoryRssSamples.push(stats.maxMemoryRss);
|
|
51
|
+
}
|
|
25
52
|
}
|
|
26
53
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
serverCompilationTimings,
|
|
55
|
+
clientCompilationTimings,
|
|
56
|
+
clientMaxMemoryRssSamples,
|
|
57
|
+
serverMaxMemoryRssSamples,
|
|
58
|
+
clientBuildTimeSamples,
|
|
59
|
+
serverBuildTimeSamples,
|
|
29
60
|
maxMemoryRssSamples,
|
|
30
61
|
};
|
|
31
62
|
};
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < REBUILD_WARMUP_TIMES; i++) {
|
|
42
|
-
await invalidate();
|
|
63
|
+
const benchmarkStart = async (di) => {
|
|
64
|
+
const { times = const_1.DEFAULT_TIMES, commandOptions } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
65
|
+
const noCache = !commandOptions.fileCache;
|
|
66
|
+
let result;
|
|
67
|
+
if (noCache) {
|
|
68
|
+
result = await runStartCommand(di, {
|
|
69
|
+
times,
|
|
70
|
+
shouldClearCache: true,
|
|
71
|
+
});
|
|
43
72
|
}
|
|
44
|
-
|
|
45
|
-
await
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
else {
|
|
74
|
+
result = await runStartCommand(di, {
|
|
75
|
+
// additional first attempt for cache warmup
|
|
76
|
+
times: times + 1,
|
|
77
|
+
shouldClearCache: false,
|
|
78
|
+
});
|
|
50
79
|
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
clientSamples,
|
|
54
|
-
serverSamples,
|
|
55
|
-
maxMemoryRssSamples,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const benchmarkStart = async (di) => {
|
|
59
|
-
const { times = 5 } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
60
|
-
const noCache = await runStartCommand(di, {
|
|
61
|
-
times: Math.max(Math.floor(times / 3), 2),
|
|
62
|
-
shouldClearCache: true,
|
|
63
|
-
});
|
|
64
|
-
const cache = await runStartCommand(di, {
|
|
65
|
-
times: Math.max(Math.floor(times / 2), 2),
|
|
66
|
-
shouldClearCache: false,
|
|
67
|
-
});
|
|
68
|
-
const rebuild = await runRebuild(di, { times });
|
|
69
|
-
return {
|
|
70
|
-
cache: (0, stats_1.getResultStats)(cache),
|
|
71
|
-
noCache: (0, stats_1.getResultStats)(noCache),
|
|
72
|
-
rebuild: (0, stats_1.getResultStats)(rebuild),
|
|
73
|
-
};
|
|
80
|
+
return (0, stats_1.getResultStats)(result);
|
|
74
81
|
};
|
|
75
82
|
exports.benchmarkStart = benchmarkStart;
|
|
76
83
|
//# sourceMappingURL=start.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/api/benchmark/start.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/api/benchmark/start.ts"],"names":[],"mappings":";;;AAGA,4CAAiF;AAGjF,mDAAyD;AACzD,yCAA+C;AAC/C,+DAAoG;AACpG,mCAAwC;AAOxC,MAAM,eAAe,GAAG,KAAK,EAC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AAK;YACL,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;KACJ;SAAM;QACL,MAAM,GAAG,MAAM,eAAe,CAAC,EAAE,EAAE;YACjC,4CAA4C;YAC5C,KAAK,EAAE,KAAK,GAAG,CAAC;YAChB,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAC;KACJ;IAED,OAAO,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;AAChC,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
|
|
@@ -1,17 +1,81 @@
|
|
|
1
|
-
export interface Stats {
|
|
2
|
-
samples: number[];
|
|
3
|
-
mean: number;
|
|
4
|
-
std: number;
|
|
5
|
-
variance: number;
|
|
6
|
-
}
|
|
7
1
|
export type Samples = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
serverCompilationTimings: CompilationStats[];
|
|
3
|
+
serverBuildTimeSamples: number[];
|
|
4
|
+
clientCompilationTimings: CompilationStats[];
|
|
5
|
+
clientBuildTimeSamples: number[];
|
|
6
|
+
maxMemoryRssSamples: number[];
|
|
7
|
+
clientMaxMemoryRssSamples: number[];
|
|
8
|
+
serverMaxMemoryRssSamples: number[];
|
|
9
|
+
};
|
|
10
|
+
export type CompilationStats = {
|
|
11
|
+
totalBuildCosts: Record<string, number>;
|
|
12
|
+
loaderBuildCosts: Record<string, number>;
|
|
13
|
+
pluginBuildCosts: Record<string, number>;
|
|
11
14
|
};
|
|
12
15
|
export type RunStats = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
serverCompilationStats: CompilationStats | undefined;
|
|
17
|
+
clientCompilationStats: CompilationStats | undefined;
|
|
18
|
+
clientBuildTime: number | undefined;
|
|
19
|
+
serverBuildTime: number | undefined;
|
|
20
|
+
clientMaxMemoryRss: number | undefined;
|
|
21
|
+
serverMaxMemoryRss: number | undefined;
|
|
22
|
+
maxMemoryRss: number | undefined;
|
|
23
|
+
};
|
|
24
|
+
type PlainObject<T = any> = {
|
|
25
|
+
[key: string]: T;
|
|
16
26
|
};
|
|
27
|
+
interface ProcessData {
|
|
28
|
+
/**
|
|
29
|
+
* process id
|
|
30
|
+
*/
|
|
31
|
+
pid: number;
|
|
32
|
+
/**
|
|
33
|
+
* parent process id
|
|
34
|
+
*/
|
|
35
|
+
ppid: number | null;
|
|
36
|
+
}
|
|
37
|
+
export interface LoaderTransformData extends ProcessData {
|
|
38
|
+
/** loader name */
|
|
39
|
+
loader: string;
|
|
40
|
+
/**
|
|
41
|
+
* loader index
|
|
42
|
+
*/
|
|
43
|
+
loaderIndex: number;
|
|
44
|
+
/** loader path */
|
|
45
|
+
path: string;
|
|
46
|
+
input: string | null | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* - isPitch: true: the result of loader.pitch()
|
|
49
|
+
* - isPitch: false: the code result of loader()
|
|
50
|
+
*/
|
|
51
|
+
result: string | null | undefined;
|
|
52
|
+
/** Timestamp when called */
|
|
53
|
+
startAt: number;
|
|
54
|
+
endAt: number;
|
|
55
|
+
/** loader configuration */
|
|
56
|
+
options: PlainObject;
|
|
57
|
+
/** pitching loader */
|
|
58
|
+
isPitch: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* is sync
|
|
61
|
+
*/
|
|
62
|
+
sync: boolean;
|
|
63
|
+
/** Error during conversion */
|
|
64
|
+
/** module layer */
|
|
65
|
+
layer?: string;
|
|
66
|
+
}
|
|
67
|
+
export type MinimalLoaderData = Pick<LoaderTransformData, 'startAt' | 'endAt' | 'pid' | 'loader'>;
|
|
68
|
+
export interface PluginData {
|
|
69
|
+
/** hook tap name */
|
|
70
|
+
tapName: string;
|
|
71
|
+
/** hook call time-consuming */
|
|
72
|
+
costs: number;
|
|
73
|
+
startAt: number;
|
|
74
|
+
endAt: number;
|
|
75
|
+
/** hook function type */
|
|
76
|
+
type: 'sync' | 'async' | 'promise';
|
|
77
|
+
/** hook function result */
|
|
78
|
+
result: any;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
17
81
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/types.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/benchmark/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,wBAAwB,EAAE,gBAAgB,EAAE,CAAC;IAC7C,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,wBAAwB,EAAE,gBAAgB,EAAE,CAAC;IAC7C,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,sBAAsB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACrD,sBAAsB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACrD,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,GAAG,GAAG,IAAI;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB,CAAC;AAEF,UAAU,WAAW;IACnB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,sBAAsB;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd,8BAA8B;IAE9B,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAElG,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACnC,2BAA2B;IAC3B,MAAM,EAAE,GAAG,CAAC;CACb"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CompilationStats } from '../types';
|
|
2
|
+
export declare function getServerCompilationTimings(benchmarkStartTime: string, attemptStartTime: number, attempt: number): Promise<CompilationStats>;
|
|
3
|
+
export declare function getClientCompilationTimings(benchmarkStartTime: string, attemptStartTime: number, attempt: number): Promise<CompilationStats>;
|
|
4
|
+
//# sourceMappingURL=compilationUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilationUtils.d.ts","sourceRoot":"","sources":["../../../../src/api/benchmark/utils/compilationUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAsD,MAAM,UAAU,CAAC;AAEhG,wBAAsB,2BAA2B,CAC/C,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,6BAGhB;AAED,wBAAsB,2BAA2B,CAC/C,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,6BAGhB"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getClientCompilationTimings = exports.getServerCompilationTimings = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
6
|
+
async function getServerCompilationTimings(benchmarkStartTime, attemptStartTime, attempt) {
|
|
7
|
+
return getCompilationTimings(benchmarkStartTime, attemptStartTime, attempt, 'server');
|
|
8
|
+
}
|
|
9
|
+
exports.getServerCompilationTimings = getServerCompilationTimings;
|
|
10
|
+
async function getClientCompilationTimings(benchmarkStartTime, attemptStartTime, attempt) {
|
|
11
|
+
return getCompilationTimings(benchmarkStartTime, attemptStartTime, attempt, 'client');
|
|
12
|
+
}
|
|
13
|
+
exports.getClientCompilationTimings = getClientCompilationTimings;
|
|
14
|
+
async function getCompilationTimings(benchmarkStartTime, attemptStartTime, attempt, type) {
|
|
15
|
+
try {
|
|
16
|
+
const rsdoctorData = await getReportData(await processReport(benchmarkStartTime, attempt, type));
|
|
17
|
+
const { summary, loader, plugin } = rsdoctorData;
|
|
18
|
+
const totalBuildCosts = calculateTotalCosts(summary, attemptStartTime);
|
|
19
|
+
const loaderBuildCosts = calculateLoadersCosts(loader);
|
|
20
|
+
const pluginBuildCosts = calculatePluginsCosts(plugin);
|
|
21
|
+
return { totalBuildCosts, loaderBuildCosts, pluginBuildCosts };
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
throw new Error(`Failed to get rsdoctor report!\n${err}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function getReportData(reportPath) {
|
|
28
|
+
const rsdoctorRawStats = await promises_1.default.readFile(reportPath, 'utf-8');
|
|
29
|
+
const rsdoctorStats = JSON.parse(rsdoctorRawStats);
|
|
30
|
+
return rsdoctorStats.data;
|
|
31
|
+
}
|
|
32
|
+
async function processReport(benchmarkStartTime, attempt, type) {
|
|
33
|
+
const reportBasePath = `./.rsdoctor/${benchmarkStartTime}`;
|
|
34
|
+
const reportPath = `${reportBasePath}/${type}-rsdoctor-data-${attempt + 1}.json`;
|
|
35
|
+
await promises_1.default.mkdir(reportBasePath, { recursive: true });
|
|
36
|
+
await promises_1.default.rename(`./.rsdoctor/${type}-rsdoctor-data.json`, reportPath);
|
|
37
|
+
return reportPath;
|
|
38
|
+
}
|
|
39
|
+
function mergeIntervals(intervals) {
|
|
40
|
+
// Sort from small to large
|
|
41
|
+
intervals.sort((a, b) => a[0] - b[0]);
|
|
42
|
+
// The previous interval, the next interval, store the result
|
|
43
|
+
let previous;
|
|
44
|
+
let current;
|
|
45
|
+
const result = [];
|
|
46
|
+
for (let i = 0; i < intervals.length; i++) {
|
|
47
|
+
current = intervals[i];
|
|
48
|
+
// If the first interval or the current interval does not overlap with the previous interval, add the current interval to the result
|
|
49
|
+
if (!previous || current[0] > previous[1]) {
|
|
50
|
+
// Assign the current interval to the previous interval
|
|
51
|
+
previous = current;
|
|
52
|
+
result.push(current);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Otherwise, the two intervals overlap
|
|
56
|
+
// Update the end time of the previous interval
|
|
57
|
+
previous[1] = Math.max(previous[1], current[1]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function getLoadersCosts(filter, loaders) {
|
|
63
|
+
const match = {};
|
|
64
|
+
const others = {};
|
|
65
|
+
loaders.forEach((e) => {
|
|
66
|
+
if (filter(e)) {
|
|
67
|
+
if (!match[e.pid])
|
|
68
|
+
match[e.pid] = [];
|
|
69
|
+
match[e.pid].push([e.startAt, e.endAt]);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (!others[e.pid])
|
|
73
|
+
others[e.pid] = [];
|
|
74
|
+
others[e.pid].push([e.startAt, e.endAt]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
let costs = 0;
|
|
78
|
+
const pids = Object.keys(match);
|
|
79
|
+
for (let i = 0; i < pids.length; i++) {
|
|
80
|
+
const pid = pids[i];
|
|
81
|
+
const _match = mergeIntervals(match[pid]);
|
|
82
|
+
// between in loader.startAt and loader.endAt
|
|
83
|
+
const _others = mergeIntervals(others[pid] || []).filter(([s, e]) => _match.some((el) => s >= el[0] && e <= el[1]));
|
|
84
|
+
// eslint-disable-next-line no-param-reassign
|
|
85
|
+
const matchSum = _match.length ? _match.reduce((t, c) => (t += c[1] - c[0]), 0) : 0;
|
|
86
|
+
// eslint-disable-next-line no-param-reassign
|
|
87
|
+
const othersSum = _others.length ? _others.reduce((t, c) => (t += c[1] - c[0]), 0) : 0;
|
|
88
|
+
costs += matchSum - othersSum;
|
|
89
|
+
}
|
|
90
|
+
return costs;
|
|
91
|
+
}
|
|
92
|
+
function calculateTotalCosts(summary, attemptStartTime) {
|
|
93
|
+
const { costs: buildCosts } = summary;
|
|
94
|
+
const buildCostsMap = buildCosts.reduce((acc, cost) => {
|
|
95
|
+
acc[cost.name] = cost;
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
const result = {};
|
|
99
|
+
for (const buildCostName in buildCostsMap) {
|
|
100
|
+
if (buildCostName === 'bootstrap->beforeCompile') {
|
|
101
|
+
// start of bootstrap is start of first build, so use attemptStarTime instead
|
|
102
|
+
result[buildCostName] =
|
|
103
|
+
buildCostsMap['beforeCompile->afterCompile'].startAt - attemptStartTime;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
result[buildCostName] = buildCostsMap[buildCostName].costs;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
function calculateLoadersCosts(loaders) {
|
|
112
|
+
const filteredLoaders = [];
|
|
113
|
+
const uniqueLoaders = new Map();
|
|
114
|
+
loaders.forEach((data) => {
|
|
115
|
+
data.loaders.forEach((fl) => {
|
|
116
|
+
const uniqueLoader = uniqueLoaders.get(fl.loader);
|
|
117
|
+
if (uniqueLoader) {
|
|
118
|
+
uniqueLoaders.set(fl.loader, {
|
|
119
|
+
files: uniqueLoader.files + 1,
|
|
120
|
+
path: fl.path,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
uniqueLoaders.set(fl.loader, { files: 1, path: fl.path });
|
|
125
|
+
}
|
|
126
|
+
return filteredLoaders.push({
|
|
127
|
+
loader: fl.loader,
|
|
128
|
+
startAt: fl.startAt,
|
|
129
|
+
endAt: fl.endAt,
|
|
130
|
+
pid: fl.pid,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
const costs = {};
|
|
135
|
+
uniqueLoaders.forEach((_, loaderName) => {
|
|
136
|
+
costs[loaderName] = getLoadersCosts((item) => item.loader === loaderName, filteredLoaders);
|
|
137
|
+
});
|
|
138
|
+
return costs;
|
|
139
|
+
}
|
|
140
|
+
function calculatePluginsCosts(plugins) {
|
|
141
|
+
const pluginCosts = {};
|
|
142
|
+
for (const hookName in plugins) {
|
|
143
|
+
const hookCalls = plugins[hookName];
|
|
144
|
+
hookCalls.forEach((plugin) => {
|
|
145
|
+
const pluginName = plugin.tapName;
|
|
146
|
+
const pluginCost = plugin.costs;
|
|
147
|
+
if (pluginCosts[pluginName]) {
|
|
148
|
+
pluginCosts[pluginName] += pluginCost;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
pluginCosts[pluginName] = pluginCost;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return pluginCosts;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=compilationUtils.js.map
|