1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | class ModuleProfile {
|
---|
9 | constructor() {
|
---|
10 | this.startTime = Date.now();
|
---|
11 |
|
---|
12 | this.factoryStartTime = 0;
|
---|
13 | this.factoryEndTime = 0;
|
---|
14 | this.factory = 0;
|
---|
15 | this.factoryParallelismFactor = 0;
|
---|
16 |
|
---|
17 | this.restoringStartTime = 0;
|
---|
18 | this.restoringEndTime = 0;
|
---|
19 | this.restoring = 0;
|
---|
20 | this.restoringParallelismFactor = 0;
|
---|
21 |
|
---|
22 | this.integrationStartTime = 0;
|
---|
23 | this.integrationEndTime = 0;
|
---|
24 | this.integration = 0;
|
---|
25 | this.integrationParallelismFactor = 0;
|
---|
26 |
|
---|
27 | this.buildingStartTime = 0;
|
---|
28 | this.buildingEndTime = 0;
|
---|
29 | this.building = 0;
|
---|
30 | this.buildingParallelismFactor = 0;
|
---|
31 |
|
---|
32 | this.storingStartTime = 0;
|
---|
33 | this.storingEndTime = 0;
|
---|
34 | this.storing = 0;
|
---|
35 | this.storingParallelismFactor = 0;
|
---|
36 |
|
---|
37 | /** @type {{ start: number, end: number }[] | undefined } */
|
---|
38 | this.additionalFactoryTimes = undefined;
|
---|
39 | this.additionalFactories = 0;
|
---|
40 | this.additionalFactoriesParallelismFactor = 0;
|
---|
41 |
|
---|
42 | /** @deprecated */
|
---|
43 | this.additionalIntegration = 0;
|
---|
44 | }
|
---|
45 |
|
---|
46 | markFactoryStart() {
|
---|
47 | this.factoryStartTime = Date.now();
|
---|
48 | }
|
---|
49 |
|
---|
50 | markFactoryEnd() {
|
---|
51 | this.factoryEndTime = Date.now();
|
---|
52 | this.factory = this.factoryEndTime - this.factoryStartTime;
|
---|
53 | }
|
---|
54 |
|
---|
55 | markRestoringStart() {
|
---|
56 | this.restoringStartTime = Date.now();
|
---|
57 | }
|
---|
58 |
|
---|
59 | markRestoringEnd() {
|
---|
60 | this.restoringEndTime = Date.now();
|
---|
61 | this.restoring = this.restoringEndTime - this.restoringStartTime;
|
---|
62 | }
|
---|
63 |
|
---|
64 | markIntegrationStart() {
|
---|
65 | this.integrationStartTime = Date.now();
|
---|
66 | }
|
---|
67 |
|
---|
68 | markIntegrationEnd() {
|
---|
69 | this.integrationEndTime = Date.now();
|
---|
70 | this.integration = this.integrationEndTime - this.integrationStartTime;
|
---|
71 | }
|
---|
72 |
|
---|
73 | markBuildingStart() {
|
---|
74 | this.buildingStartTime = Date.now();
|
---|
75 | }
|
---|
76 |
|
---|
77 | markBuildingEnd() {
|
---|
78 | this.buildingEndTime = Date.now();
|
---|
79 | this.building = this.buildingEndTime - this.buildingStartTime;
|
---|
80 | }
|
---|
81 |
|
---|
82 | markStoringStart() {
|
---|
83 | this.storingStartTime = Date.now();
|
---|
84 | }
|
---|
85 |
|
---|
86 | markStoringEnd() {
|
---|
87 | this.storingEndTime = Date.now();
|
---|
88 | this.storing = this.storingEndTime - this.storingStartTime;
|
---|
89 | }
|
---|
90 |
|
---|
91 | // This depends on timing so we ignore it for coverage
|
---|
92 | /* istanbul ignore next */
|
---|
93 | /**
|
---|
94 | * Merge this profile into another one
|
---|
95 | * @param {ModuleProfile} realProfile the profile to merge into
|
---|
96 | * @returns {void}
|
---|
97 | */
|
---|
98 | mergeInto(realProfile) {
|
---|
99 | realProfile.additionalFactories = this.factory;
|
---|
100 | (realProfile.additionalFactoryTimes =
|
---|
101 | realProfile.additionalFactoryTimes || []).push({
|
---|
102 | start: this.factoryStartTime,
|
---|
103 | end: this.factoryEndTime
|
---|
104 | });
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | module.exports = ModuleProfile;
|
---|