提交 8d1cba6b 编写于 作者: A andrewleo

Added: add debug log to monitor network traffic & update version and readme

上级 0bfc4ae4
......@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.netease.qa.emmagee"
android:versionCode="30"
android:versionName="2.0" >
android:versionName="2.1" >
<uses-sdk android:minSdkVersion="8" />
......
......@@ -42,7 +42,7 @@ And Enjoy!
If you want to stop the test, just go back to Emmagee and click Stop button.
## Coming Soon
* Integrating FPS
* We want you to decide!
## How to Contribute?
......@@ -56,11 +56,12 @@ You are welcome to contribute to Emmagee, meanwhile you'd better follow the rule
## Contributors
* NetEase, Inc.
* [yrom](https://github.com/yrom)
* [LukeOwncloud](https://github.com/LukeOwncloud)
## License
(The Apache License)
Copyright (c) 2012-2014 NetEase, Inc. and other contributors
Copyright (c) 2012-2015 NetEase, Inc. and other contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
......@@ -441,7 +441,7 @@ public class EmmageeService extends Service {
String processCpuRatio = "0.00";
String totalCpuRatio = "0.00";
String trafficSize = "0";
int tempTraffic = 0;
long tempTraffic = 0L;
double trafficMb = 0;
boolean isMb = false;
if (!processInfo.isEmpty()) {
......@@ -449,7 +449,7 @@ public class EmmageeService extends Service {
totalCpuRatio = processInfo.get(1);
trafficSize = processInfo.get(2);
if (!(BLANK_STRING.equals(trafficSize)) && !("-1".equals(trafficSize))) {
tempTraffic = Integer.parseInt(trafficSize);
tempTraffic = Long.parseLong(trafficSize);
if (tempTraffic > 1024) {
isMb = true;
trafficMb = (double) tempTraffic / 1024;
......
......@@ -260,8 +260,11 @@ public class CpuInfo {
lastestTraffic = trafficInfo.getTrafficInfo();
if (initialTraffic == -1)
traffic = -1;
else
else {
traffic = (lastestTraffic - initialTraffic + 1023) / 1024;
}
Log.d(LOG_TAG, "lastestTraffic===" + lastestTraffic);
Log.d(LOG_TAG, "initialTraffic===" + initialTraffic);
StringBuffer totalCpuBuffer = new StringBuffer();
if (null != totalCpu2 && totalCpu2.size() > 0) {
processCpuRatio = fomart.format(100 * ((double) (processCpu - processCpu2) / ((double) (totalCpu.get(0) - totalCpu2.get(0)))));
......
......@@ -29,8 +29,7 @@ import android.util.Log;
*/
public class TrafficInfo {
private static final String LOG_TAG = "Emmagee-"
+ TrafficInfo.class.getSimpleName();
private static final String LOG_TAG = "Emmagee-" + TrafficInfo.class.getSimpleName();
private String uid;
......@@ -46,6 +45,7 @@ public class TrafficInfo {
*/
public long getTrafficInfo() {
Log.i(LOG_TAG, "get traffic information");
Log.d(LOG_TAG, "uid===" + uid);
RandomAccessFile rafRcv = null, rafSnd = null;
String rcvPath = "/proc/uid_stat/" + uid + "/tcp_rcv";
String sndPath = "/proc/uid_stat/" + uid + "/tcp_snd";
......@@ -73,10 +73,11 @@ public class TrafficInfo {
if (rafSnd != null)
rafSnd.close();
} catch (IOException e) {
Log.i(LOG_TAG,
"close randomAccessFile exception: " + e.getMessage());
Log.i(LOG_TAG, "close randomAccessFile exception: " + e.getMessage());
}
}
Log.d(LOG_TAG, "rcvTraffic===" + rcvTraffic);
Log.d(LOG_TAG, "sndTraffic===" + sndTraffic);
if (rcvTraffic == -1 || sndTraffic == -1) {
return -1;
} else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册