博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
带monkey的测流量!
阅读量:6503 次
发布时间:2019-06-24

本文共 3603 字,大约阅读时间需要 12 分钟。

  hot3.png

//public static  void flow(){

//String command1 ="adb shell monkey -p com.netease.newsreader.activity -s 500 -v 2000";

//String command2 = "adb shell ps";

//String str="com.netease.newsreader.activity";

//String SIBaseVersion = " ";

//String SIBaseVersion3 = " ";

//String SIBaseVersion4= " ";

WLAN流量和

//int FWlan=0;

3/4G网流量和

//int FNet=0;

//try {

//Runtime runtime = Runtime.getRuntime();

//

//Process getSIBaseVersionProcess2 = runtime.exec(command2);

//Process getSIBaseVersionProcess1 = runtime.exec(command1);

//BufferedReader bufferedReader = new BufferedReader(

//new InputStreamReader(

//getSIBaseVersionProcess2.getInputStream()));

//while ((SIBaseVersion = bufferedReader.readLine()) != null) {

将字符串数组重新添加到list集合中,在从集合中获取相应的值

// List<String> tmp = new ArrayList<String>(); 

//if ( isHave(SIBaseVersion, str) ) {

String s = SIBaseVersion;

截取需要的字符串

//String[] array = SIBaseVersion.split(" ");

//for (int i = 0; i < array.length; i++) {

//if (array[i].length() != 0) {

//tmp.add(array[i]);

//}

//}

取list集合中的数据

//String H1 = tmp.get(1);

转换成整型

//int Pid = Integer.parseInt(H1);

//String command3 = "adb shell cat /proc/" + Pid + "/status | grep Uid";

//Process getSIBaseVersionProcess3 = runtime.exec(command3);

//BufferedReader bufferedReader3 = new BufferedReader(

//new InputStreamReader(getSIBaseVersionProcess3.getInputStream()));

//while (((SIBaseVersion3 = bufferedReader3.readLine()) != null)) {

//List<String>tmp2 = new ArrayList<String>();

//if (!(SIBaseVersion3.equals(""))) {

//String[] array1 = SIBaseVersion3.split("\t");

//for (int i = 0; i < array1.length; i++) {

//tmp2.add(array1[i]);

//}

取list集合中的数据

//String U1 = tmp2.get(1);

转换成整型

//int Uid = Integer.parseInt(U1);

//String command4 = "adb shell cat /proc/net/xt_qtaguid/stats | grep " + Uid;

//Process getSIBaseVersionProcess4 = runtime.exec(command4);

//BufferedReader bufferedReader4 = new BufferedReader(

//new InputStreamReader(getSIBaseVersionProcess4.getInputStream()));

//while ((SIBaseVersion4 = bufferedReader4.readLine()) != null) {

//String rmnet = "rmnet0";

//String wlan = "wlan0";

//List<String> tmp4 = new ArrayList<String>(); 

//if (isHave(SIBaseVersion4, wlan)) {

//String[] Wlanarray = SIBaseVersion4.split(" ");

//for (int i = 0; i < Wlanarray.length; i++) {

//if (Wlanarray[i].length() != 0) {

//tmp4.add(Wlanarray[i]);

//

//}

//}

挑选自己需要的数据

//if (tmp4.get(2).equals("0x0")&&tmp4.get(4).equals("1")) {

//String Wlan1 =tmp4.get(5);

// String Wlan2 =tmp4.get(7);

//转换成双精度

// double WLAN1 = Double.parseDouble(Wlan1);

//double WLAN2 = Double.parseDouble(Wlan2);

//double W = WLAN1+WLAN2;

//FWlan+=W;

//}

//}

//List<String> tmp3 = new ArrayList<String>(); 

//if (isHave(SIBaseVersion4, rmnet)) {

//String[] Netarray = SIBaseVersion4.split(" ");

//for (int i = 0; i < Netarray.length; i++) {

//if (Netarray[i].length() != 0) {

//tmp3.add(Netarray[i]);

//}

//}

//if (tmp3.get(2).equals("0x0")&&tmp3.get(4).equals("1")) {

//String Net1 = tmp3.get(5);

//String Net2 = tmp3.get(7);

//double NET1 = Double.parseDouble(Net1);

//double NET2 = Double.parseDouble(Net2);

//double N=NET1+NET2;

//FNet+=N;

//}

//}

//}

输出相应流量值

//System.err.println("FWlan1 ="+1.0*FWlan/1024);

//System.err.println("FNET1 ="+1.0*FNet/1024);

//bufferedReader4.close();

//getSIBaseVersionProcess4.destroy();

//}

//

//}

//bufferedReader3.close();

//getSIBaseVersionProcess3.destroy();

//}

//}

//

//bufferedReader.close();

//getSIBaseVersionProcess2.destroy();

//getSIBaseVersionProcess1.destroy();

//

//} catch (Exception e) {

//System.out.println("[Error][getSIBaseVersion]" + e.getMessage());

//}

//}

 

转载于:https://my.oschina.net/MStart/blog/607838

你可能感兴趣的文章
Notepad++ 也支持 TypeScript 了
查看>>
Android Camera 相机开发详解
查看>>
利用 squid 反向代理提高网站性能原理总结
查看>>
&& 和 || 运算符的特殊用法记录
查看>>
eruke注册中心搭建
查看>>
c++,lua交互
查看>>
Linux Shell: 统计系统中占用Swap 的程序PID和占用大小
查看>>
Java通过JNI的方式调用C
查看>>
AOSuite V3.0 发布,开源JavaEE快速开发平台
查看>>
myeclipse提示“Project must be an XFire project”
查看>>
layui 之 upload组件
查看>>
进阶Java架构师必看的15本书
查看>>
uva 400 - Unix ls
查看>>
基本数据结构之ArrayList
查看>>
Eclipse引入JRE中类提示出错
查看>>
maven命令及使用
查看>>
activity在配置只支持竖屏时要注意个问题
查看>>
EditText
查看>>
1、Spark-Streaming的原理
查看>>
关于android监视器
查看>>