publicclassMainActivity extends Activity {
TabHost tabHost;
publicvoidonCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//性能测试起点
Debug.startMethodTracing("burgleaf");//关键语句
tabHost =(TabHost)this.findViewById(R.id.tabhost);
tabHost.setup();
}
@Override
//当activity销毁的时候调用Debug.stopMethodTracing()方法终止测试
protectedvoidonDestroy(){
Debug.stopMethodTracing();
super.onDestroy();
}
privateViewcreateTabView(String name)
{
View tabView =getLayoutInflater().inflate(R.layout.tab,null);
TextView textView =(TextView)tabView.findViewById(R.id.name);
textView.setText(name);
return tabView;
}
}
该语句,根据测试只能放置在一个activity中,会统计在这个activity中涉及的线程所消耗的资源。
放在Application层,似乎不起作用