2012-07-20 31 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();