| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ModuleProfile { | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							|  |  |  | 		this.startTime = Date.now(); | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		this.factoryStartTime = 0; | 
					
						
							|  |  |  | 		this.factoryEndTime = 0; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 		this.factory = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.factoryParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		this.restoringStartTime = 0; | 
					
						
							|  |  |  | 		this.restoringEndTime = 0; | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 		this.restoring = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.restoringParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		this.integrationStartTime = 0; | 
					
						
							|  |  |  | 		this.integrationEndTime = 0; | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		this.integration = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.integrationParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		this.buildingStartTime = 0; | 
					
						
							|  |  |  | 		this.buildingEndTime = 0; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 		this.building = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.buildingParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		this.storingStartTime = 0; | 
					
						
							|  |  |  | 		this.storingEndTime = 0; | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 		this.storing = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.storingParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 01:13:03 +08:00
										 |  |  | 		/** @type {{ start: number, end: number }[] | undefined } */ | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.additionalFactoryTimes = undefined; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 		this.additionalFactories = 0; | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		this.additionalFactoriesParallelismFactor = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** @deprecated */ | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		this.additionalIntegration = 0; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	markFactoryStart() { | 
					
						
							|  |  |  | 		this.factoryStartTime = Date.now(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	markFactoryEnd() { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.factoryEndTime = Date.now(); | 
					
						
							|  |  |  | 		this.factory = this.factoryEndTime - this.factoryStartTime; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 	markRestoringStart() { | 
					
						
							|  |  |  | 		this.restoringStartTime = Date.now(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	markRestoringEnd() { | 
					
						
							|  |  |  | 		this.restoringEndTime = Date.now(); | 
					
						
							|  |  |  | 		this.restoring = this.restoringEndTime - this.restoringStartTime; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	markIntegrationStart() { | 
					
						
							|  |  |  | 		this.integrationStartTime = Date.now(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	markIntegrationEnd() { | 
					
						
							|  |  |  | 		this.integrationEndTime = Date.now(); | 
					
						
							|  |  |  | 		this.integration = this.integrationEndTime - this.integrationStartTime; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	markBuildingStart() { | 
					
						
							|  |  |  | 		this.buildingStartTime = Date.now(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	markBuildingEnd() { | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		this.buildingEndTime = Date.now(); | 
					
						
							|  |  |  | 		this.building = this.buildingEndTime - this.buildingStartTime; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 	markStoringStart() { | 
					
						
							|  |  |  | 		this.storingStartTime = Date.now(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	markStoringEnd() { | 
					
						
							|  |  |  | 		this.storingEndTime = Date.now(); | 
					
						
							|  |  |  | 		this.storing = this.storingEndTime - this.storingStartTime; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-21 22:29:13 +08:00
										 |  |  | 	// This depends on timing so we ignore it for coverage
 | 
					
						
							|  |  |  | 	/* istanbul ignore next */ | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Merge this profile into another one | 
					
						
							|  |  |  | 	 * @param {ModuleProfile} realProfile the profile to merge into | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	mergeInto(realProfile) { | 
					
						
							| 
									
										
										
										
											2021-02-02 08:22:19 +08:00
										 |  |  | 		realProfile.additionalFactories = this.factory; | 
					
						
							|  |  |  | 		(realProfile.additionalFactoryTimes = | 
					
						
							|  |  |  | 			realProfile.additionalFactoryTimes || []).push({ | 
					
						
							|  |  |  | 			start: this.factoryStartTime, | 
					
						
							|  |  |  | 			end: this.factoryEndTime | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ModuleProfile; |