def measure_energy(oldEnergy=None):
    newEnergy = {}

    executable = find_executable('read-energy.sh', exitOnError=False)
    if executable is None: # not available on current system
        logging.debug(
            'Energy measurement not available because read-energy.sh could not be found.')
        return newEnergy

    for energyType in ENERGY_TYPES:
        logging.debug('Reading %s energy measurement for value.', energyType)
        energysh = subprocess.Popen([executable, energyType], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (stdout, stderr) = energysh.communicate()
        if energysh.returncode or stderr:
            logging.debug('Error while reading %s energy measurement: retval=%s, out=%s, err=%s',
                          energyType, energysh.returncode, stdout, stderr)
        try:
            newEnergy[energyType] = int(stdout)
        except ValueError:
            logging.debug('Invalid value while reading %s energy measurement: %s',
                          energyType, stdout)

    logging.debug('Finished reading energy measurements.')

    if oldEnergy is None:
        return newEnergy
    else:
        return _energy_difference(newEnergy, oldEnergy)
returns a dictionary with the currently available values of energy consumptions (like a time-stamp).
dataset/ETHPy150Open sosy-lab/benchexec/benchexec/util.py/measure_energy