2012-07-20 67 views

回答

2

您可以使用DDMS和Systrace打破你的应用程序正在这样做和多久。

至于“基准测试”,你是什么意思?你想看看在你的应用中做些什么需要多长时间? 确保您以尽可能最快的方式做事,而不是在特定的时间范围内,通常更有用。

+1

我这样没问什么我的应用程序在做什么。我想看看基准。 – 2012-07-20 01:10:51

+1

你不能只是“测试”一个应用程序,除非有一些特定的处理是你想要的。你想知道什么? – 2012-07-20 01:12:26

+0

是的,我想这么久我的应用程序需要它正在做的事情。 – 2012-07-20 01:13:15

1

我编写了一个代码来专门测试我想要的代码的特定部分。你可以在这里找到: http://farzad.devbro.com/android_benchmark/Devbro_Benchmark.java

下面是代码示例使用:

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(); 
相关问题