UNPKG

@cloud-carbon-footprint/core

Version:

The core logic to get cloud usage data and estimate energy and carbon emissions.

27 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("../."); class MemoryEstimator { constructor(coefficient) { this.coefficient = coefficient; } estimate(data, region, emissionsFactors, constants) { return data.map((data) => { const estimatedKilowattHours = this.estimateKilowattHours(data.gigabyteHours, constants.powerUsageEffectiveness, constants.replicationFactor); const estimatedCO2Emissions = (0, _1.estimateCo2)(estimatedKilowattHours, region, emissionsFactors); return { timestamp: data.timestamp, kilowattHours: estimatedKilowattHours, co2e: estimatedCO2Emissions, }; }); } estimateKilowattHours(gigabyteHours, powerUsageEffectiveness, replicationFactor = 1) { return (gigabyteHours * this.coefficient * powerUsageEffectiveness * replicationFactor); } } exports.default = MemoryEstimator; //# sourceMappingURL=MemoryEstimator.js.map