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 | this.additionalFactoryTimes = undefined;
|
---|
38 | this.additionalFactories = 0;
|
---|
39 | this.additionalFactoriesParallelismFactor = 0;
|
---|
40 |
|
---|
41 | /** @deprecated */
|
---|
42 | this.additionalIntegration = 0;
|
---|
43 | }
|
---|
44 |
|
---|
45 | markFactoryStart() {
|
---|
46 | this.factoryStartTime = Date.now();
|
---|
47 | }
|
---|
48 |
|
---|
49 | markFactoryEnd() {
|
---|
50 | this.factoryEndTime = Date.now();
|
---|
51 | this.factory = this.factoryEndTime - this.factoryStartTime;
|
---|
52 | }
|
---|
53 |
|
---|
54 | markRestoringStart() {
|
---|
55 | this.restoringStartTime = Date.now();
|
---|
56 | }
|
---|
57 |
|
---|
58 | markRestoringEnd() {
|
---|
59 | this.restoringEndTime = Date.now();
|
---|
60 | this.restoring = this.restoringEndTime - this.restoringStartTime;
|
---|
61 | }
|
---|
62 |
|
---|
63 | markIntegrationStart() {
|
---|
64 | this.integrationStartTime = Date.now();
|
---|
65 | }
|
---|
66 |
|
---|
67 | markIntegrationEnd() {
|
---|
68 | this.integrationEndTime = Date.now();
|
---|
69 | this.integration = this.integrationEndTime - this.integrationStartTime;
|
---|
70 | }
|
---|
71 |
|
---|
72 | markBuildingStart() {
|
---|
73 | this.buildingStartTime = Date.now();
|
---|
74 | }
|
---|
75 |
|
---|
76 | markBuildingEnd() {
|
---|
77 | this.buildingEndTime = Date.now();
|
---|
78 | this.building = this.buildingEndTime - this.buildingStartTime;
|
---|
79 | }
|
---|
80 |
|
---|
81 | markStoringStart() {
|
---|
82 | this.storingStartTime = Date.now();
|
---|
83 | }
|
---|
84 |
|
---|
85 | markStoringEnd() {
|
---|
86 | this.storingEndTime = Date.now();
|
---|
87 | this.storing = this.storingEndTime - this.storingStartTime;
|
---|
88 | }
|
---|
89 |
|
---|
90 | // This depends on timing so we ignore it for coverage
|
---|
91 | /* istanbul ignore next */
|
---|
92 | /**
|
---|
93 | * Merge this profile into another one
|
---|
94 | * @param {ModuleProfile} realProfile the profile to merge into
|
---|
95 | * @returns {void}
|
---|
96 | */
|
---|
97 | mergeInto(realProfile) {
|
---|
98 | realProfile.additionalFactories = this.factory;
|
---|
99 | (realProfile.additionalFactoryTimes =
|
---|
100 | realProfile.additionalFactoryTimes || []).push({
|
---|
101 | start: this.factoryStartTime,
|
---|
102 | end: this.factoryEndTime
|
---|
103 | });
|
---|
104 | }
|
---|
105 | }
|
---|
106 |
|
---|
107 | module.exports = ModuleProfile;
|
---|