获取帧率

    //获取帧率
    public static String getgfx(String packagename) throws IOException
    {
        Process process=Runtime.getRuntime().exec("adb shell dumpsys gfxinfo "+packagename);
        BufferedReader br=new BufferedReader(new InputStreamReader(process.getInputStream()));
        String str;
        int dropf=0;
        int allgfx=0;

        while((str=br.readLine())!=null)
        {  
            Pattern p=Pattern.compile("^[^a-zA-Z]\\d+\\.\\d+");
            Matcher m=p.matcher(str);
           
            float total1=0;
            int mult;
                if(m.find())
                {   
                    allgfx++;
                    System.out.println(str);
                    for(int i=0;i<4;i++)
                    {              
                    total1+=Float.parseFloat(str.trim().split("    ")[i]);
    
                    }

                    if((mult=(int) (total1/16.67))>0)
                    {   
                        for(int i=mult;i>0;i--)
                        {
                            dropf++;
                        }
                        
                    }
                        
                }
                

        }
        //计算帆帧率
        float percent1;
        percent1=(float)allgfx/(allgfx+dropf);
        System.out.println("总共执行了"+allgfx+"帧,掉了"+dropf+"帧");
        System.out.println("帧率百分比为:"+percent1);
        DecimalFormat df = new DecimalFormat("0.0");
        String s=df.format(percent1*60);
                
        return s;
        
       
    
        
    }

 

转载于:https://www.cnblogs.com/penghong2014/p/5818030.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值