Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
244509aa
E
emmagee
项目概览
weixin_47647075
/
emmagee
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
emmagee
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
244509aa
编写于
1月 05, 2014
作者:
A
andrewleo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed: #15 usage rate of CPU is negative
上级
e384d9a8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
28 deletion
+27
-28
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+19
-18
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+8
-10
未找到文件。
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
244509aa
...
...
@@ -464,25 +464,26 @@ public class EmmageeService extends Service {
trafficMb
=
(
double
)
tempTraffic
/
1024
;
}
}
// 如果cpu使用率存在且都不小于0,则输出
if
(
processCpuRatio
!=
null
&&
totalCpuRatio
!=
null
)
{
txtUnusedMem
.
setText
(
"应用/剩余内存:"
+
processMemory
+
"/"
+
freeMemoryKb
+
"MB"
);
txtTotalMem
.
setText
(
"应用/总体CPU:"
+
processCpuRatio
+
"%/"
+
totalCpuRatio
+
"%"
);
String
batt
=
"电流:"
+
currentBatt
;
if
(
"-1"
.
equals
(
trafficSize
))
{
txtTraffic
.
setText
(
batt
+
",流量:N/A"
);
}
else
if
(
isMb
)
txtTraffic
.
setText
(
batt
+
",流量:"
+
fomart
.
format
(
trafficMb
)
+
"MB"
);
else
txtTraffic
.
setText
(
batt
+
",流量:"
+
trafficSize
+
"KB"
);
}
// 当内存为0切cpu使用率为0时则是被测应用退出
if
(
"0"
.
equals
(
processMemory
)
&&
"0.00"
.
equals
(
processCpuRatio
))
{
closeOpenedStream
();
isServiceStop
=
true
;
return
;
}
}
// 如果cpu使用率存在且都不小于0,则输出
if
(
processCpuRatio
!=
null
&&
totalCpuRatio
!=
null
)
{
txtUnusedMem
.
setText
(
"应用/剩余内存:"
+
processMemory
+
"/"
+
freeMemoryKb
+
"MB"
);
txtTotalMem
.
setText
(
"应用/总体CPU:"
+
processCpuRatio
+
"%/"
+
totalCpuRatio
+
"%"
);
String
batt
=
"电流:"
+
currentBatt
;
if
(
"-1"
.
equals
(
trafficSize
))
{
txtTraffic
.
setText
(
batt
+
",流量:N/A"
);
}
else
if
(
isMb
)
txtTraffic
.
setText
(
batt
+
",流量:"
+
fomart
.
format
(
trafficMb
)
+
"MB"
);
else
txtTraffic
.
setText
(
batt
+
",流量:"
+
trafficSize
+
"KB"
);
}
// 当内存为0切cpu使用率为0时则是被测应用退出
if
(
"0"
.
equals
(
processMemory
)
&&
"0.00"
.
equals
(
processCpuRatio
))
{
closeOpenedStream
();
isServiceStop
=
true
;
return
;
}
}
}
...
...
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
244509aa
...
...
@@ -177,13 +177,11 @@ public class CpuInfo {
percent
=
fomart
.
format
(((
double
)
pidMemory
/
(
double
)
totalMemorySize
)
*
100
);
}
// 当应用的cpu使用率大于0时才写入文件中,过滤掉异常数据
if
(
isDouble
(
processCpuRatio
)
&&
isDouble
(
totalCpuRatio
))
{
if
(
isPositive
(
processCpuRatio
)
&&
isPositive
(
totalCpuRatio
))
{
// whether certain device supports traffic statics or not
if
(
traffic
==
-
1
)
{
if
(
traffic
==
-
1
)
{
EmmageeService
.
bw
.
write
(
mDateTime2
+
","
+
pMemory
+
","
+
percent
+
","
+
fMemory
+
","
+
processCpuRatio
+
","
+
totalCpuRatio
+
","
+
"N/A"
+
","
+
totalBatt
+
","
+
currentBatt
+
","
+
temperature
+
","
+
voltage
+
"\r\n"
);
+
totalCpuRatio
+
","
+
"N/A"
+
","
+
totalBatt
+
","
+
currentBatt
+
","
+
temperature
+
","
+
voltage
+
"\r\n"
);
}
else
{
EmmageeService
.
bw
.
write
(
mDateTime2
+
","
+
pMemory
+
","
+
percent
+
","
+
fMemory
+
","
+
processCpuRatio
+
","
+
totalCpuRatio
+
","
+
traffic
+
","
+
totalBatt
+
","
+
currentBatt
+
","
+
temperature
+
","
+
voltage
+
"\r\n"
);
...
...
@@ -198,24 +196,24 @@ public class CpuInfo {
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// PttService.closeOpenedStream()
}
return
cpuUsedRatio
;
}
/**
*
判断text是否是一个double类型数据
*
is text a positive number
*
* @param text
* @return
*/
private
boolean
isDouble
(
String
text
)
{
private
boolean
isPositive
(
String
text
)
{
Double
num
;
try
{
Double
.
parseDouble
(
text
);
num
=
Double
.
parseDouble
(
text
);
}
catch
(
NumberFormatException
e
)
{
return
false
;
}
return
true
;
return
num
>=
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录