Skip to content

Commit

Permalink
Added: add debug log to monitor network traffic & update version and …
Browse files Browse the repository at this point in the history
…readme
  • Loading branch information
andrewleo committed Dec 29, 2014
1 parent 0bfc4ae commit 8d1cba6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/com/netease/qa/emmagee/service/EmmageeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ private void dataRefresh() {
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()) {
processCpuRatio = processInfo.get(0);
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;
Expand Down
5 changes: 4 additions & 1 deletion src/com/netease/qa/emmagee/utils/CpuInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ public ArrayList<String> getCpuRatioInfo(String totalBatt, String currentBatt, S
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)))));
Expand Down
9 changes: 5 additions & 4 deletions src/com/netease/qa/emmagee/utils/TrafficInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
*/
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;

Expand All @@ -46,6 +45,7 @@ public TrafficInfo(String uid) {
*/
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";
Expand Down Expand Up @@ -73,10 +73,11 @@ public long getTrafficInfo() {
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
Expand Down

0 comments on commit 8d1cba6

Please sign in to comment.