# How to measure energy consumption of computations?

**URL:** https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578
**Category:** General Usage
**Created:** [May 5, 2021, 1:23pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578 "2021-05-05T13:23:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![scheidan1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheidan1/32/24771_2.png) [@scheidan1](https://discourse.julialang.org/u/scheidan1)
#### Post date: [May 5, 2021, 1:23pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/1 "2021-05-05T13:23:36Z")

</div>

Developing models and running simulations is a core activity of our research department. Faster languages (Julia) and better algorithms result typically not in less computation, but in more ambitious targets. During a discussion about how we can minimize our environmental footprint, we realized that we do not have an idea how much energy our simulations require.

I was therefore wondering if there is a easy way to measure the energy consumption of long running computations? It doesn’t need to very accurate.

The closest I found was [`pyJoules`](https://github.com/powerapi-ng/pyJoules) “to measure the energy footprint of a host machine along the execution of a piece of Python code.”

Maybe [powertop](https://01.org/powertop/) (a Linux tool) could be used, but did not figure out how the measure the energy consumption of a single process.

Thanks for any hints!

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [May 5, 2021, 3:35pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/2 "2021-05-05T15:35:45Z")

</div>

You could measure the electrical energy consumed by the machine you’re running the simulation on (using simple hardware), it’s going to be far more accurate than a software solution.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [May 5, 2021, 3:38pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/3 "2021-05-05T15:38:11Z")

</div>

I once saw a paper which compared energy efficiency of different languages, maybe you can dig it up.

---

<div class="post-metadata">

### Author: ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)
#### Post date: [May 5, 2021, 4:34pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/4 "2021-05-05T16:34:40Z")

</div>

Measuring energy consumption of your hardware is trivial when running your simulations locally, but impossible for cloud based calculations (unless the cloud provider offers it).  
Other aspects that should be considered:

- Where does the energy come from? Renewables or coal?
- Environmental impact of your hardware production

---

<div class="post-metadata">

### Author: ![scheidan1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheidan1/32/24771_2.png) [@scheidan1](https://discourse.julialang.org/u/scheidan1)
#### Post date: [May 6, 2021, 8:47am UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/5 "2021-05-06T08:47:01Z")

</div>

Thanks for your suggestions!

Measuring the electricity consumption directly seems like the best option for non-cloud computations. Maybe one should subtract the baseline consumption if the computer is running anyway.

Life-cycle costs for hardware should be considered indeed. I’m sure we can find studies about this (with all the related uncertainties).

Using renewable energy is not free pass given the still limited supply. If I use more renewables, my neighbor can use less.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [May 6, 2021, 9:10am UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/6 "2021-05-06T09:10:44Z")

</div>

Here the paper I was referring to above being discussed:  
[https://www.reddit.com/r/Julia/comments/jg3stz/julias\_energy\_efficiency\_relative\_to\_other/](https://www.reddit.com/r/Julia/comments/jg3stz/julias_energy_efficiency_relative_to_other/)

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [May 6, 2021, 1:47pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/7 "2021-05-06T13:47:31Z")

</div>

> [@scheidan1](#):
>
> we realized that we do not have an idea how much energy our simulations require

For _comparison_ of various alternatives, I would just keep it simple and use _runtime as a proxy_ (on the same hardware). If you have reasonable core utilization, it will be fairly accurate.

If you really want energy, measure the consumption of that hardware running a typical load for a specific duration of time and convert.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [May 6, 2021, 4:02pm UTC](https://discourse.julialang.org/t/how-to-measure-energy-consumption-of-computations/60578/8 "2021-05-06T16:02:51Z")

</div>

> [@scheidan1](#):
>
> During a discussion about how we can minimize our environmental footprint

What I’m really _curious_ is the environmental footprint of running zilions of CI tests, that might be quite heavy, for trivial changes, that can be as useless as running them when only document parts have been changed.
