Hello everyone,
Firstly, thank you for the creation of Perfetto! Really allows developers to inspect the performance of their Android apps. Great work! Secondly, I hope this is the right place to ask my questions. I know this is the dev mailing list but I came across some questions about general usage here as well so I assume its okay? If not, apologies :).
Just FYI: to do measurements I'm using the record_android_trace help script :).My questions:1. How to get the battery counters data in a human readable format? I can access the data using the Perfetto UI and the SQL query engine. However, when using the trace conversion tool and convert my trace to json or systrace I get unexpected (to me atleast ;p) output:
When converting to json: https://pastebin.com/vb0i4SmmWhen converting to systrace format: https://pastebin.com/auDuayCCWhen converting to text I get the following error:[982.531] trace_to_text.cc:153 Cannot open protos/perfetto/trace/trace_packet.proto.[982.531] trace_to_text.cc:156 Text mode only works from the perfetto directory. Googlers, see b/131425913
Is there a way to get the battery counters data in a human readable format?
2. Does Android Perfetto provides a builtin way to get the amount of energy used in Joules during its runtime?
3. How can I see whether the power rails data source is available on my device? The website states: This data source has been introduced in Android 10 (Q) and requires the dedicated hardware on the device. This hardware is not yet available on most production phones. Is there an overview of supported devices? I'm using a Pixel 5 running Android 11.
4. How do I do actually do power measurements using the power rails data source? Do I only need to set the collect_power_rails: to true in my android_power_config as mentioned here.
Will this give me data for all available rails on the device (given of course, that the device contains the dedicated hardware for doing power rails measurements)
5. According to the website measuring power consumption using battery counters while the device is connected through USB can result in invalid measurements.
Would using adb shell dumpsys battery unplug help in this case?
Thanks a lot!--
You received this message because you are subscribed to the Google Groups "Perfetto Development - www.perfetto.dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to perfetto-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/perfetto-dev/138591e5-bf7a-4912-8136-abe047c0c0b2n%40googlegroups.com.
Hello Primiano,Thanks a lot for your quick and detailed response and apologies for my slow one... Thanks to your help I've been doing some experiments with Perfetto and I really like the way your can customize your measurement setup. However, I still have a few questions which I can't figure out reading the docs.>> Yes absolutely. If you want some more interactive interaction feel free to drop by our discord channel on https://discord.gg/35ShE3A>> This ML works as well.Thats great! I will join the channel! However, I will also ask my questions here as I like how a ML functions as a knowledge base :). Maybe other people find our discussion useful as well.1. Regarding the measuring power consumption when the device is connected through USB. Right now I'm programmatically disabling the USB ports of my laptop before starting the trace using ADB WiFi debugging.
However, this actually results in my batt.current_ua values to become negative numbers! When I keep my device connected through USB and run a perfetto trace the batt.current_ua values are positive. Isn't this the opposite of what is expected to happen? I'm using a Google Pixel 5 running Android 11.
2. When running experiments (with my USB ports disabled so the device is not receiving power through USB) my traces show a constant batt.charge_uah value: it does not change overtime. Even when doing longer traces (1 minute or longer) the value stays the same. Is this to be expected? Am I missing something?
3. When querying my data for ex:I also receive a timestamp (ts). From what I've read this is time according to BUILTIN_CLOCK_BOOTTIME? Is it possible to instead timestamp the data from the point of starting the trace in ms? So when tracing for 60 seconds. we have ts values between 0 and 60000? So similarly as when viewing your trace in the ui.perfetto.dev viewer? Or can I convert these existing timestamps to this format I? I've already looked at the primary_trace_clock from the builtin_data_sources but it didn't work. For example I added the following lines to my perfetto_config.pbtx:
builtin_data_sources:{primary_trace_clock: BUILTIN_CLOCK_REALTIME}But I didn't see any differences.4. I assumed that the value set for battery_poll_ms corresponds with the number of measurements. So when setting it to 250ms (4 times per second) over a period of 1 minute I would assume 60*4=240 measurements. However, for a 1 minutetrace I just get 124 measurements. Are my assumptions incorrect? If so why ;p?
To view this discussion on the web visit https://groups.google.com/d/msgid/perfetto-dev/c737e17f-e987-4c01-bffe-5625112c3ec7n%40googlegroups.com.
Again thanks for the response!>> WDYM with "disabling"? If you mean via software, that most of the time doesn't disable the power feed of the USB port. I suspect that's what's happening here, you are disabling the port logically but not electrically.I was looking over the documentation again and I found the following about the current_ua on the TracePacket documentation page[1]:Instantaneous battery current in microamperes(µA). Positive values indicate net current entering the battery from a charge source, negative values indicate net current discharging from the battery.On the "Battery counters and rails" page [2] however it states:Battery counters measure the charge flowing in and out of the battery. If the device is plugged to a USB cable, you will likely observe a negative instantaneous current and an increase of the total charge, denoting the fact that charge is flowing in the battery (i.e. charging it) rather than out.Maybe I'm reading it incorrectly (I'm not an English native speaker and its midnight here ;p) but don't these sources say the opposite?
I indeed disable it via software using uhubctl[0] however I just did a trace with the phone completely disconnected from USB, using just WiFi debugging. This gives me the same problem: a negative batt.current_ua. According to the TracePacket documentation page this is correct but according to the Battery counters and rails page this is incorrect?>> See aboveI see that there is a change in the the batt.charge_uah value! However, over a period of 60 seconds its just a single change. After 46 seconds it goes directly from 4,002,240uah to 3,960,550uah. Is there a way to get this to be more accurate i.e. more finegrained/higher granularity, so also the values between 4,002,240uah to 3,960,550uah?
To view this discussion on the web visit https://groups.google.com/d/msgid/perfetto-dev/a7b9d897-6123-4261-b16a-e9880c0ba62fn%40googlegroups.com.