Search code examples
javascriptandroidperformanceconsumption

Is there a way to determine which part of JS code is most power consumptive?


I am developing a JavaScript game and then I would like to "phonegap" it to the mobile platform, specifically Android. It is a well known fact that these non-native apps could be really power consuming when run on mobile, so I would like to optimize it the best.

Is there a way to determine which part of the code, or which function is the most power consumptive? Some sort of a JS debugger, which would tell me how much time it took to run that part of the code - or which would tell me which part I should rewrite?

Optimization is a tricky process and I know it, but I wanted to give this a shot.

Thanks in advance.


Solution

  • Assuming that power profile consumption on desktop browsers is the same (or similar) to the mobile one, you can use the Google Chrome JS Profiler.

    It would also be interesting on an "academic level" if you could provide some comparison between mobile and desktop here.