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();
|
|
|
|
this.factory = 0;
|
2018-09-07 21:51:27 +08:00
|
|
|
this.integration = 0;
|
2018-08-22 20:54:28 +08:00
|
|
|
this.building = 0;
|
|
|
|
this.additionalFactories = 0;
|
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-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-07 21:51:27 +08:00
|
|
|
mergeInto(realProfile) {
|
|
|
|
if (this.factory > realProfile.additionalFactories)
|
|
|
|
realProfile.additionalFactories = this.factory;
|
|
|
|
if (this.integration > realProfile.additionalIntegration)
|
|
|
|
realProfile.additionalIntegration = this.integration;
|
2018-08-22 20:54:28 +08:00
|
|
|
return realProfile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ModuleProfile;
|