Created
January 23, 2025 13:07
-
-
Save thibaudcolas/1c8010be2109e51f4f1a12d5bd178f02 to your computer and use it in GitHub Desktop.
Digital Carbon Rating Scale of SWD v4, re-calculated with CO2.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { co2 } from "@tgwf/co2"; | |
const swdmV4 = new co2({ model: "swd", version: 4 }); | |
// Figures as of 2025-01-23 | |
// https://sustainablewebdesign.org/digital-carbon-ratings/ | |
const ratings = { | |
"A+": 272.51, | |
A: 531.15, | |
B: 975.85, | |
C: 1410.39, | |
D: 1875.01, | |
E: 2419.56, | |
F: 2419.57, | |
}; | |
/** | |
* Re-calculate the Digital Carbon Rating Scale thresholds for each percentile transfer size, | |
* to compare with official figures. | |
*/ | |
Object.entries(ratings).forEach(([rating, ratingValue]) => { | |
const estimate = swdmV4.perVisitTrace(ratingValue * 1000, false, { | |
gridIntensity: { | |
device: 494, | |
dataCenter: 494, | |
networks: 494, | |
}, | |
firstVisitPercentage: 1, | |
returnVisitPercentage: 0, | |
dataReloadRatio: 0, | |
}); | |
console.log(`${rating}: ${estimate.co2}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment