简体   繁体   中英

How to benchmark android application?

At work I am using Ubuntu and at home I am using windows 7. I would like to know how can I benchmark my android application on Ubuntu and windows 7.

You can use DDMS and Systrace to break down what your app is doing and for how long.

As for "benchmarking," what do you mean by that? Do you want to see how long it takes to do something in your app? It's usually more useful to just make sure you're doing things in the fastest way possible, rather than within a certain time window.

I wrote a code to specifically benchmark specific part of the code that I want. you can find it here: http://farzad.devbro.com/android_benchmark/Devbro_Benchmark.java

Here is an example of the code to use:

Devbro_Benchmark.markStart("Label2"); //mark a begining
for(int i=0;i<1000;i++)
{
    //you can create multiple markers at once. If you use the same marker name
    //it will simply add up the times for you
    Devbro_Benchmark.markStart("Label1");
    //some random code
    Devbro_Benchmark.markEnd("Label");
}
Devbro_Benchmark.markEnd("Label2"); // mark an ending

//once you are done with your markers you can display an extensive report which will be
//shown using the Log.d
Devbro_Benchmark.print_report();

//once you are done you can reset before redoing it.
Devbro_Benchmark.reset();

There are now two Jetpack benchmarking libraries . from the Android team.

Macrobenchmarking : Allows you to benchmark entire workflows

Microbenchmarking : Enables benchmarking specific code in isolation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM