powerapi-ng / pyJoules

A Python library to capture the energy consumption of code snippets
MIT License
70 stars 10 forks source link

Measure Raspberry Pi Energy #33

Open hafizuriu opened 8 months ago

hafizuriu commented 8 months ago

Hi, is it possible to measure energy of raspberry pi. I tried it but failed to measure.

It shows an error-

Traceback (most recent call last):
  File "/home/master-pi/test.py", line 7, in <module>
    main()
  File "/home/master-pi/.local/lib/python3.11/site-packages/pyJoules/energy_meter.py", line 298, in wrapper_measure
    handler.process(energy_meter.get_trace())
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-pi/.local/lib/python3.11/site-packages/pyJoules/energy_meter.py", line 160, in get_trace
    return self._generate_trace()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-pi/.local/lib/python3.11/site-packages/pyJoules/energy_meter.py", line 169, in _generate_trace
    domains = self._get_domain_list()
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-pi/.local/lib/python3.11/site-packages/pyJoules/energy_meter.py", line 166, in _get_domain_list
    return reduce(operator.add, [device.get_configured_domains() for device in self.devices])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: reduce() of empty iterable with no initial value