webpack/lib/ModuleProfile.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

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;
this.integration = 0;
2018-08-22 20:54:28 +08:00
this.building = 0;
this.additionalFactories = 0;
this.additionalIntegration = 0;
2018-08-22 20:54:28 +08:00
}
markFactoryStart() {
this.factoryStartTime = Date.now();
}
2018-08-22 20:54:28 +08:00
markFactoryEnd() {
this.factoryEndTime = Date.now();
this.factory = this.factoryEndTime - this.factoryStartTime;
2018-08-22 20:54:28 +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() {
this.buildingEndTime = Date.now();
this.building = this.buildingEndTime - this.buildingStartTime;
2018-08-22 20:54:28 +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;