{"id":16254184,"url":"https://github.com/sumn2u/node-carbon","last_synced_at":"2025-04-08T13:14:33.966Z","repository":{"id":208739196,"uuid":"722374671","full_name":"sumn2u/node-carbon","owner":"sumn2u","description":"Calculate carbon footprints of current node process.","archived":false,"fork":false,"pushed_at":"2023-12-07T15:59:38.000Z","size":719,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T09:20:28.646Z","etag":null,"topics":["carbon-footprint","cpu-usage","memory-usage","node","node-process","nodejs"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sumn2u.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-23T02:25:10.000Z","updated_at":"2024-04-15T16:19:46.000Z","dependencies_parsed_at":"2023-12-19T01:00:49.287Z","dependency_job_id":"dd854902-8854-4ce3-8dda-794b55b7bdd0","html_url":"https://github.com/sumn2u/node-carbon","commit_stats":{"total_commits":36,"total_committers":4,"mean_commits":9.0,"dds":"0.33333333333333337","last_synced_commit":"fd22f85679331b8a11c90d308679c4ecfeb2e197"},"previous_names":["sumn2u/node-carbon"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumn2u%2Fnode-carbon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumn2u%2Fnode-carbon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumn2u%2Fnode-carbon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumn2u%2Fnode-carbon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sumn2u","download_url":"https://codeload.github.com/sumn2u/node-carbon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247847611,"owners_count":21006100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carbon-footprint","cpu-usage","memory-usage","node","node-process","nodejs"],"created_at":"2024-10-10T15:20:23.563Z","updated_at":"2025-04-08T13:14:33.948Z","avatar_url":"https://github.com/sumn2u.png","language":"Jupyter Notebook","readme":"# 🌱 Node Carbon: A Node Package for Measuring Carbon Footprints 🌐\n\nEver pondered the environmental impact of your Node.js processes? Enter Node Carbon – your solution for calculating the carbon footprint of your current Node.js operations.\n\n[![status](https://joss.theoj.org/papers/2319047071d2f0e14401ca3ced73c0c0/status.svg)](https://joss.theoj.org/papers/2319047071d2f0e14401ca3ced73c0c0)\n\u003cspan class=\"badge-npmversion\"\u003e\u003ca href=\"https://npmjs.org/package/node-carbon\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/node-carbon.svg\" alt=\"NPM version\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://npmjs.org/package/node-carbon\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/node-carbon.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e\n[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Test Workflow](https://github.com/sumn2u/node-carbon/workflows/Test%20Workflow/badge.svg)](https://github.com/sumn2u/node-carbon/actions)\n\u003ca href=\"https://metrics.green-coding.berlin/stats.html?id=26fac0a1-429b-4575-b156-dc7eaa7d380e\"\u003e\u003cimg src=\"https://api.green-coding.berlin/v1/badge/single/26fac0a1-429b-4575-b156-dc7eaa7d380e?metric=AC\"\u003e\u003c/a\u003e\n\n\n\n## Why Measure Your Carbon Footprint? 🌍\n\nUnderstanding the carbon footprint of your Node.js processes is crucial for businesses, organizations, and individuals striving to minimize their environmental impact and enhance resource efficiency. As we collectively aim for a greener future, Node Carbon empowers you to make informed decisions and take proactive steps towards sustainability.\n\n## How Does Node Carbon Work? ⚙️\n\nNode Carbon estimates the electricity consumption of your hardware (CPU+RAM) and then applies the carbon intensity specific to the region where the computing is taking place. This comprehensive approach ensures that you get an accurate and localized assessment of your digital carbon footprint.\n\n![Carbon Emission Calculation](https://raw.githubusercontent.com/sumn2u/node-carbon/main/paper/carbon_emission.png)\n\n\n## Key Features  🔍\n\n1. **Precision in Measurement:** Node Carbon provides a detailed breakdown of electricity consumption, considering the specific hardware components involved in your Node.js processes.\n\n2. **Regional Carbon Intensity:** By factoring in the carbon intensity of the region where your computations occur, Node Carbon offers a nuanced understanding of the environmental impact.\n\n3. **Empowering Sustainable Choices:** Armed with insights from Node Carbon, you can make informed decisions to optimize resource usage, reduce energy consumption, and contribute to a more sustainable digital ecosystem.\n\n\n## Get Started Today! 🚀\n\nReady to take the first step towards a greener digital footprint? Node Carbon is here to help. Calculate, analyze, and optimize your Node.js processes for a more sustainable future. Install node carbon.\n\n```bash\nnpm install node-carbon --save-dev\nyarn add node-carbon --dev # or yarn\n```\n\n## Example\n\n```js\nconst nodeCarbon = new NodeCarbon();\n\n// Get energy information about the current network provider\nconst energyInfo = await nodeCarbon.getEnergyInfo();\nconsole.log(\"Energy info\", energyInfo);\n\n// start logging energy usage\nawait nodeCarbon.start();\n\nsetTimeout(async () =\u003e {\n  // Stop carbon logging of current process\n  const carbon = await nodeCarbon.stop();\n  console.table({\n  'CPU Usage (watts)': carbon.cpuUsageInfo.cpuUsage,\n  'Total Time (s)': carbon.elapsedTime,\n  'RSS Delta (Mb)': carbon.memoryUsageInfo.rssDeltaMB,\n  'Heap Total Delta (Mb)': carbon.memoryUsageInfo.heapTotalDeltaMB,\n  'Heap Used Delta (Mb)': carbon.memoryUsageInfo.heapUsedDeltaMB,\n  'Carbon Consumption (gCO2e/kWh)': carbon.carbonEmission\n});\n}, 1000);\n```\n\n| Metric                                   | Unit         |\n| ---------------------------------------- | ------------ |\n| CPU Usage                                | watts        |\n| Elapsed Time                             | seconds      |\n| Memory Usage (RSS Delta)                  | Mb           |\n| Memory Usage (Heap Total Delta)           | Mb           |\n| Memory Usage (Heap Used Delta)            | Mb           |\n| Carbon Emission                          | gCO2e/kWh    |\n\n## Functions\n\n| Name        | Description |\n| ------------------ | ----------- |\n| `getEnergyInfo()` | Gives information about the energy grid of the connected network and its composition. |\n| `start()`          | Starts logging the hardware energy consumption. |\n| `end()`            | Computes the carbon emission based on the computation power usage and regional carbon intensity. |\n| `startMeasurementWithInterval(milliseconds)`            | Measures carbon consumption in an interval (milliseconds). |\n| `stopPowerMeasurement()`            | Clear the timer interval set in `startMeasurementWithInterval()`. |\n\n\n## Testing\n\n```bash\n yarn test\n```\n\n## Experiments\nExperiments with different packages are done [here](https://github.com/sumn2u/node-carbon/tree/experiments/experiments).\n\n## Support\nThis package supports Node.js versions between `\u003e= 16.0.0` and `\u003c= 21.0.0`. Here's an experimental setup with [various version](https://github.com/sumn2u/node-carbon/actions/runs/7060937460/job/19221532726).\n\n## TODOs\n- Develop a more effective method for measuring the power consumption of RAM.\n\n## Contributing\n\n1. Fork and clone it\n1. Install dependencies: `npm install`\n1. Create a feature branch: `git checkout -b new-feature`\n1. Commit changes: `git commit -am 'Added a feature'`\n1. Run static code analysis and unit tests: `npm test`\n1. Push to the remote branch: `git push origin new-feature`\n1. Create a new [Pull Request](https://github.com/sumn2u/node-carbon/pull/new/main)\n\n## License\n\nCode released under the [MIT license](./LICENSE).\n\n","funding_links":[],"categories":["Carbon Footprint (EEIO or LCA models)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumn2u%2Fnode-carbon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsumn2u%2Fnode-carbon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumn2u%2Fnode-carbon/lists"}