powerapi-ng / pyRAPL

a library to measure the python energy consumption of python code
MIT License
100 stars 9 forks source link

API proposal #1

Closed rouvoy closed 4 years ago

rouvoy commented 4 years ago

What about providing an API like this:

import pyRAPL

rapl = pyRAPL.PyRAPL()
record = rapl.record(pyRAPL.PKG|pyRAPL.DRAM)
foo()
bar()
record.stop()
pkg_energy = record.energy(pyRAPL.PKG)
dram_energy = record.energy(pyRAPL.DRAM)

with the supported masks: pyRAPL.PKG, pyRAPL.DRAM, pyRAPL.GPU, pyRAPL.ALL

This can be the basis for being included in a ContextManager and/or code annotation.

altor commented 4 years ago

ok maybe using a list of constant instead of bitwise operation ?

rouvoy commented 4 years ago

ok, the most important thing is to keep it simple and compact.