wakatime / wakatime-cli

Command line interface used by all WakaTime text editor plugins
https://wakatime.com/plugins
BSD 3-Clause "New" or "Revised" License
266 stars 41 forks source link

Power / energy monitoring #1000

Closed muety closed 5 months ago

muety commented 6 months ago

Please take this as a thought sparker, rather than an actual feature request. I recently got a bit into the topic of green IT / sustainable software development and find it super interesting to get insights about the energy consumption of the software I develop as well as the development process itself.

Quite amazing tools, such as scaphandre, exist, alongside lower-level tools like powertop or the Intel RAPL API. They can be used to get estimated power draw measurements (e.g. in Watts) from your computer's CPU at any time. Of course that's not accurate and, if any, rather a lower-bound for the actual energy consumption (power supply, hard drives, etc. are not included), but still interesting in my opinion.

On desktop computers, you'll only get the power draw estimates reported by your CPU and GPU, which are, of course, only ballpark numbers. On laptops, however, the energy consumption could probably actually be measured quite accurately, because you can directly get the difference in battery charging state between any two points in time.

I was wondering if there is a good way to integrate power monitoring with WakaTime. Perhaps every heartbeat could include a power measurement in Watts, between which the backend then interpolates to calculate a rough estimate of the energy consumed (in Wh or Joules) on a specific project, branch, etc.

alanhamlett commented 6 months ago

Energy usage and RAM usage by editor would be interesting, but I think a more generic monitoring tool is better suited. Something that's meant to track all running applications on the machine, not just IDEs.

Related, we have profiling that's opt-in with the metrics config. It's only saved locally on your computer, not sent to the api:

https://github.com/wakatime/wakatime-cli/blob/a675bbcc558d83fe6cd2e49d73b8cd0bbd8ab493/pkg/metrics/metrics.go#L17