BayLibre / iio-capture

Simple capture and metrics computation tools based on iio-readdev
2 stars 1 forks source link

[Energy] Discrepancy in energy computation with respect to another probe #2

Closed mdigiorgio closed 8 years ago

mdigiorgio commented 8 years ago

Hello,

I'm trying to use iio-capture in order to measure energy consumption on a device and I got very different results in the energy value with respect to what I measure with a different probe. In particular, the energy value reported by iio-capture is 25 times lower than what is measured by the other probe.

In order to understand which is wrong (or more accurate), I measured the energy consumption of a 2.70 Ohm resistor over which I apply a 4.03 V voltage and a current of 1.50 A for roughly 20 seconds. Therefore, the energy value should be 120.90 J.

What I measure is:

All the other values reported be iio-capture look reasonable, except for energy:

<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=vbus_max RESULT=pass UNITS=mV MEASUREMENT=4030.00>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=energy RESULT=pass UNITS=mJ MEASUREMENT=4610.26>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=power_min RESULT=pass UNITS=mW MEASUREMENT=6025.00>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=power_max RESULT=pass UNITS=mW MEASUREMENT=6050.00>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=power_avg RESULT=pass UNITS=mW MEASUREMENT=6025.02>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=current_min RESULT=pass UNITS=mA MEASUREMENT=1496.00>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=current_max RESULT=pass UNITS=mA MEASUREMENT=1500.00>

Do you have any idea why I'm getting incorrect results?

mtitinger commented 8 years ago

Hi Michele,

nice to hear that you got so far with ACME. The Energy computation is basically "Instant-power" times "sampling period" accumulated over each samples. It is indeed likely to be arguable as a computation. I did not expect it to be that off though. I will look into it.

mtitinger commented 8 years ago

The code was mainly missing to apply the scale of the power channel, hence the 1:25 ratio. With the added patches it should be OK.

While playing with different integration time settings, I came across a glitch, but I think this is an issue driver side, maybe an integration time value that is not properly applied when writing in sysfs. Anyway, currently the sampling freq is not an option, I now set it to 114Hz so that at least 4 probes can record simultaneously with an accurate sampling rate. I will do more validation and add a sampling freq option when I get a chance.

mdigiorgio commented 8 years ago

Hi Marc,

OK thanks for the quick update, I will give it a try as soon as possible.

mdigiorgio commented 8 years ago

Nice! I can now read the correct value. Thanks for the fixes.

Also, the duration argument is a useful tool. However, sometimes the workload duration is unknown and so sending SIGTERM to stop recording is very useful. I think the default behaviour should be the previous one, where you were recording until CTRL+C is hit (you can achieve the same by setting a very long duration, but in my opinion is not very nice to have hard-coded values in the tests). What do you think?

mtitinger commented 8 years ago

On 02/06/2016 12:24, Michele Di Giorgio wrote:

Nice! I can now read the correct value. Thanks for the fixes.

Cool, thanks for the update :)

Also, the duration argument is a useful tool. However, sometimes the workload duration is unknown and so sending SIGTERM to stop recording is very useful. I think the default behaviour should be the previous one, where you were recording until CTRL+C is hit (you can achieve the same by setting a very long duration, but in my opinion is not very nice to have hard-coded values in the tests). What do you think?

-d/duration was for testing mainly, it should work like previously w/o this option, I will fix this suddenly, my bad.

BR, M.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BayLibre/iio-capture/issues/2#issuecomment-223253432, or mute the thread https://github.com/notifications/unsubscribe/AH6JKHl4-vD3f1CkRFV64XY8qmLBjRrNks5qHq9kgaJpZM4IqoGh.

mdigiorgio commented 8 years ago

Minor issue: when printing the help you get a (null) in the explanation of the --buffer-size option:

$ iio-capture -h
Usage:
        iio-capture [-n <hostname>] [-f <fout>] [-b <buffer-size>] [-d] [-e] [-c] [-o]<iio_device> [<channel> ...]

Options:
        -h, --help
                        Show this help and quit.
        -c, --csv
                        Output values to a Comma-Separated-Values file.
        -d, --duration
                        Duration in milli-seconds for the record (based on driver timestamps).
        -e, --energy-only
                        Oneline style output format, instead of LAVA format.
        -o, --one-line
                        Use the network backend with the provided hostname.
        -n, --network
                        Output values to specified filename as binary or CSV when '-c'.
        -f, --fout
                        Size of the capture buffer. Default is 256.
        -b, --buffer-size
                        (null)

You are missing the energy-only explanation in https://github.com/BayLibre/iio-capture/blob/master/iio-capture.c#L88

mtitinger commented 8 years ago

fixed, thanks.

mdigiorgio commented 8 years ago

Thanks for the patches..

This issue can be closed as of patchset 6559a3...8ee052