ModuleProfile.js 2.4 KB

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