Measuring Processing Power

With either VS Code or Eclipse is there a simple way to measure how much more resources are being used by changes to your code? For example, how much more processing power will I use if I  to add a function to change text color based on different values like heart rate?

  • Have you looked into the profiler that's available in 4.1.1?

  • The profiler sounds like a good idea, but I'm not sure that will translate execution times, etc. accurately into battery power consumption, which is what I think you're ultimately after, but I'm not sure.

    If power is your final goal, you can monitor the battery percentage down to several decimal places, although I don't think anything more than the first 2 or 3 really matter, and the 3rd is probably not all that reliable.  Write two apps, one with each approach, and put in a battery monitor report (yeah, that also increases the power, but it should show the delta between the two apps if that part is the same in both).  Run each app for about an hour or so and note the battery start/end percentages.  One caveat, the battery discharge isn't perfectly linear, so for best results start/end each app at the same battery levels, or as close as possible.

    My gut feel is if the only difference is one branch and instruction to set the text color, that probably isn't going to change much of anything in a typical program.

  • Yes, battery drain is my real concern. I'm not sure the best way to run a battery monitor report but i'll do some searches to learn more. thanks!

  • you can get the current battery percentage using this:

    System.getSystemStats().battery;

    you could map it to a key and manually press the key after a measured time, or you could integrate it into a timer in your program that retrieves the information periodically and displays it on the screen.  Many different ways to do that part of it.