Debug.startMethodTracing 去检测程序的性能

来源:互联网 发布:undefined动作数据 编辑:程序博客网 时间:2024/04/27 23:06

publicclassMainActivityextends 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层,似乎不起作用


原创粉丝点击