Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
5f6d8e36
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
大约 1 年 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f6d8e36
编写于
5月 16, 2019
作者:
Y
yixiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
性能曲线图 代码重构,代码收口到基类
上级
038c2053
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
122 addition
and
160 deletion
+122
-160
iOS/DoraemonKit/Src/Core/CommonUI/Oscillogram/DoraemonOscillogramViewController.h
.../CommonUI/Oscillogram/DoraemonOscillogramViewController.h
+8
-0
iOS/DoraemonKit/Src/Core/CommonUI/Oscillogram/DoraemonOscillogramViewController.m
.../CommonUI/Oscillogram/DoraemonOscillogramViewController.m
+65
-0
iOS/DoraemonKit/Src/Core/Plugin/CPU/Function/DoraemonCPUOscillogramViewController.m
...lugin/CPU/Function/DoraemonCPUOscillogramViewController.m
+12
-43
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSOscillogramViewController.m
...lugin/FPS/Function/DoraemonFPSOscillogramViewController.m
+15
-30
iOS/DoraemonKit/Src/Core/Plugin/Memory/Function/DoraemonMemoryOscillogramViewController.m
...Memory/Function/DoraemonMemoryOscillogramViewController.m
+11
-44
iOS/DoraemonKit/Src/Core/Plugin/NetFlow/Function/View/DoraemonNetFlowOscillogramViewController.m
.../Function/View/DoraemonNetFlowOscillogramViewController.m
+11
-43
未找到文件。
iOS/DoraemonKit/Src/Core/CommonUI/Oscillogram/DoraemonOscillogramViewController.h
浏览文件 @
5f6d8e36
...
...
@@ -6,10 +6,18 @@
//
#import <UIKit/UIKit.h>
#import "DoraemonOscillogramView.h"
@interface
DoraemonOscillogramViewController
:
UIViewController
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
-
(
NSString
*
)
title
;
-
(
NSString
*
)
lowValue
;
-
(
NSString
*
)
highValue
;
-
(
void
)
closeBtnClick
;
-
(
void
)
startRecord
;
-
(
void
)
endRecord
;
-
(
void
)
doSecondFunction
;
@end
iOS/DoraemonKit/Src/Core/CommonUI/Oscillogram/DoraemonOscillogramViewController.m
浏览文件 @
5f6d8e36
...
...
@@ -10,9 +10,74 @@
@interface
DoraemonOscillogramViewController
()
//每秒运行一次
@property
(
nonatomic
,
strong
)
NSTimer
*
secondTimer
;
@end
@implementation
DoraemonOscillogramViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
UILabel
*
titleLabel
=
[[
UILabel
alloc
]
init
];
titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
titleLabel
.
text
=
[
self
title
];
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
20
)];
titleLabel
.
textColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
titleLabel
];
[
titleLabel
sizeToFit
];
titleLabel
.
frame
=
CGRectMake
(
kDoraemonSizeFrom750_Landscape
(
20
),
IPHONE_TOPSENSOR_HEIGHT
+
kDoraemonSizeFrom750_Landscape
(
10
),
titleLabel
.
doraemon_width
,
titleLabel
.
doraemon_height
);
UIButton
*
closeBtn
=
[[
UIButton
alloc
]
init
];
[
closeBtn
setImage
:[
UIImage
doraemon_imageNamed
:
@"doraemon_close_white"
]
forState
:
UIControlStateNormal
];
closeBtn
.
frame
=
CGRectMake
((
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
)
-
kDoraemonSizeFrom750_Landscape
(
60
),
IPHONE_TOPSENSOR_HEIGHT
,
kDoraemonSizeFrom750_Landscape
(
60
),
kDoraemonSizeFrom750_Landscape
(
60
));
[
closeBtn
addTarget
:
self
action
:
@selector
(
closeBtnClick
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
closeBtn
];
_oscillogramView
=
[[
DoraemonOscillogramView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
titleLabel
.
doraemon_bottom
+
kDoraemonSizeFrom750_Landscape
(
24
),
(
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
),
kDoraemonSizeFrom750_Landscape
(
400
))];
_oscillogramView
.
backgroundColor
=
[
UIColor
clearColor
];
[
_oscillogramView
setLowValue
:[
self
lowValue
]];
[
_oscillogramView
setHightValue
:[
self
highValue
]];
[
self
.
view
addSubview
:
_oscillogramView
];
}
-
(
NSString
*
)
title
{
return
@""
;
}
-
(
NSString
*
)
lowValue
{
return
@"0"
;
}
-
(
NSString
*
)
highValue
{
return
@"100"
;
}
-
(
void
)
closeBtnClick
{
}
-
(
void
)
startRecord
{
if
(
!
_secondTimer
){
_secondTimer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
f
target
:
self
selector
:
@selector
(
doSecondFunction
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
currentRunLoop
]
addTimer
:
_secondTimer
forMode
:
NSRunLoopCommonModes
];
}
}
-
(
void
)
doSecondFunction
{
}
-
(
void
)
endRecord
{
if
(
_secondTimer
){
[
_secondTimer
invalidate
];
_secondTimer
=
nil
;
[
self
.
oscillogramView
clear
];
}
}
-
(
void
)
viewWillTransitionToSize
:(
CGSize
)
size
withTransitionCoordinator
:(
id
<
UIViewControllerTransitionCoordinator
>
)
coordinator
{
[
super
viewWillTransitionToSize
:
size
withTransitionCoordinator
:
coordinator
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
...
...
iOS/DoraemonKit/Src/Core/Plugin/CPU/Function/DoraemonCPUOscillogramViewController.m
浏览文件 @
5f6d8e36
...
...
@@ -14,11 +14,6 @@
@interface
DoraemonCPUOscillogramViewController
()
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
//每秒运行一次
@property
(
nonatomic
,
strong
)
NSTimer
*
secondTimer
;
@end
...
...
@@ -26,49 +21,23 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
UILabel
*
titleLabel
=
[[
UILabel
alloc
]
init
];
titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
titleLabel
.
text
=
DoraemonLocalizedString
(
@"CPU检测"
);
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
20
)];
titleLabel
.
textColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
titleLabel
];
[
titleLabel
sizeToFit
];
titleLabel
.
frame
=
CGRectMake
(
kDoraemonSizeFrom750_Landscape
(
20
),
IPHONE_TOPSENSOR_HEIGHT
+
kDoraemonSizeFrom750_Landscape
(
10
),
titleLabel
.
doraemon_width
,
titleLabel
.
doraemon_height
);
UIButton
*
closeBtn
=
[[
UIButton
alloc
]
init
];
[
closeBtn
setImage
:[
UIImage
doraemon_imageNamed
:
@"doraemon_close_white"
]
forState
:
UIControlStateNormal
];
closeBtn
.
frame
=
CGRectMake
((
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
)
-
kDoraemonSizeFrom750_Landscape
(
60
),
IPHONE_TOPSENSOR_HEIGHT
,
kDoraemonSizeFrom750_Landscape
(
60
),
kDoraemonSizeFrom750_Landscape
(
60
));
[
closeBtn
addTarget
:
self
action
:
@selector
(
closeBtnClick
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
closeBtn
];
_oscillogramView
=
[[
DoraemonOscillogramView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
titleLabel
.
doraemon_bottom
+
kDoraemonSizeFrom750_Landscape
(
24
),
(
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
),
kDoraemonSizeFrom750_Landscape
(
400
))];
_oscillogramView
.
backgroundColor
=
[
UIColor
clearColor
];
[
_oscillogramView
setLowValue
:
@"0"
];
[
_oscillogramView
setHightValue
:
@"100"
];
[
self
.
view
addSubview
:
_oscillogramView
];
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveCpuSwitch
:
NO
];
[[
DoraemonCPUOscillogramWindow
shareInstance
]
hide
];
-
(
NSString
*
)
title
{
return
DoraemonLocalizedString
(
@"CPU检测"
);
}
-
(
void
)
startRecord
{
if
(
!
_secondTimer
){
_secondTimer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
f
target
:
self
selector
:
@selector
(
doSecondFunction
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
currentRunLoop
]
addTimer
:
_secondTimer
forMode
:
NSRunLoopCommonModes
];
}
-
(
NSString
*
)
lowValue
{
return
@"0"
;
}
-
(
void
)
endRecord
{
if
(
_secondTimer
){
[
_secondTimer
invalidate
];
_secondTimer
=
nil
;
[
_oscillogramView
clear
];
}
-
(
NSString
*
)
highValue
{
return
@"100"
;
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveCpuSwitch
:
NO
];
[[
DoraemonCPUOscillogramWindow
shareInstance
]
hide
];
}
//每一秒钟采样一次cpu使用率
...
...
@@ -81,7 +50,7 @@
}
// 0~100 对应 高度0~_oscillogramView.doraemon_height
NSTimeInterval
time
=
[[
NSDate
date
]
timeIntervalSince1970
];
[
_oscillogramView
addHeightValue
:
cpuUsage
*
_
oscillogramView
.
doraemon_height
/
100
.
andTipValue
:[
NSString
stringWithFormat
:
@"%.f"
,
cpuUsage
]];
[
self
.
oscillogramView
addHeightValue
:
cpuUsage
*
self
.
oscillogramView
.
doraemon_height
/
100
.
andTipValue
:[
NSString
stringWithFormat
:
@"%.f"
,
cpuUsage
]];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSOscillogramViewController.m
浏览文件 @
5f6d8e36
...
...
@@ -15,7 +15,6 @@
@interface
DoraemonFPSOscillogramViewController
()
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
@property
(
nonatomic
,
strong
)
DoraemonFPSUtil
*
fpsUtil
;
@end
...
...
@@ -24,35 +23,21 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
UILabel
*
titleLabel
=
[[
UILabel
alloc
]
init
];
titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
titleLabel
.
text
=
DoraemonLocalizedString
(
@"帧率检测"
);
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
20
)];
titleLabel
.
textColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
titleLabel
];
[
titleLabel
sizeToFit
];
titleLabel
.
frame
=
CGRectMake
(
kDoraemonSizeFrom750_Landscape
(
20
),
IPHONE_TOPSENSOR_HEIGHT
+
kDoraemonSizeFrom750_Landscape
(
10
),
titleLabel
.
doraemon_width
,
titleLabel
.
doraemon_height
);
UIButton
*
closeBtn
=
[[
UIButton
alloc
]
init
];
[
closeBtn
setImage
:[
UIImage
doraemon_imageNamed
:
@"doraemon_close_white"
]
forState
:
UIControlStateNormal
];
closeBtn
.
frame
=
CGRectMake
((
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
)
-
kDoraemonSizeFrom750_Landscape
(
60
),
IPHONE_TOPSENSOR_HEIGHT
,
kDoraemonSizeFrom750_Landscape
(
60
),
kDoraemonSizeFrom750_Landscape
(
60
));
[
closeBtn
addTarget
:
self
action
:
@selector
(
closeBtnClick
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
closeBtn
];
_oscillogramView
=
[[
DoraemonOscillogramView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
titleLabel
.
doraemon_bottom
+
kDoraemonSizeFrom750_Landscape
(
24
),
(
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
),
kDoraemonSizeFrom750_Landscape
(
400
))];
_oscillogramView
.
backgroundColor
=
[
UIColor
clearColor
];
[
_oscillogramView
setLowValue
:
@"0"
];
[
_oscillogramView
setHightValue
:
@"60"
];
[
self
.
view
addSubview
:
_oscillogramView
];
}
-
(
NSString
*
)
title
{
return
DoraemonLocalizedString
(
@"帧率检测"
);
}
-
(
NSString
*
)
lowValue
{
return
@"0"
;
}
-
(
NSString
*
)
highValue
{
return
@"60"
;
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveFpsSwitch
:
NO
];
[[
DoraemonFPSOscillogramWindow
shareInstance
]
hide
];
...
...
@@ -64,7 +49,7 @@
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_fpsUtil
addFPSBlock
:
^
(
NSInteger
fps
)
{
// 0~60 对应 高度0~_oscillogramView.doraemon_height
[
weakSelf
.
oscillogramView
addHeightValue
:
fps
*
_
oscillogramView
.
doraemon_height
/
60
.
andTipValue
:[
NSString
stringWithFormat
:
@"%zi"
,
fps
]];
[
weakSelf
.
oscillogramView
addHeightValue
:
fps
*
weakSelf
.
oscillogramView
.
doraemon_height
/
60
.
andTipValue
:[
NSString
stringWithFormat
:
@"%zi"
,
fps
]];
}];
}
[
_fpsUtil
start
];
...
...
@@ -74,7 +59,7 @@
if
(
_fpsUtil
)
{
[
_fpsUtil
end
];
}
[
_
oscillogramView
clear
];
[
self
.
oscillogramView
clear
];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Memory/Function/DoraemonMemoryOscillogramViewController.m
浏览文件 @
5f6d8e36
...
...
@@ -15,62 +15,29 @@
@interface
DoraemonMemoryOscillogramViewController
()
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
//每秒运行一次
@property
(
nonatomic
,
strong
)
NSTimer
*
secondTimer
;
@end
@implementation
DoraemonMemoryOscillogramViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
UILabel
*
titleLabel
=
[[
UILabel
alloc
]
init
];
titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
titleLabel
.
text
=
DoraemonLocalizedString
(
@"内存检测"
);
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
20
)];
titleLabel
.
textColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
titleLabel
];
[
titleLabel
sizeToFit
];
titleLabel
.
frame
=
CGRectMake
(
kDoraemonSizeFrom750_Landscape
(
20
),
IPHONE_TOPSENSOR_HEIGHT
+
kDoraemonSizeFrom750_Landscape
(
10
),
titleLabel
.
doraemon_width
,
titleLabel
.
doraemon_height
);
UIButton
*
closeBtn
=
[[
UIButton
alloc
]
init
];
[
closeBtn
setImage
:[
UIImage
doraemon_imageNamed
:
@"doraemon_close_white"
]
forState
:
UIControlStateNormal
];
closeBtn
.
frame
=
CGRectMake
((
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
)
-
kDoraemonSizeFrom750_Landscape
(
60
),
IPHONE_TOPSENSOR_HEIGHT
,
kDoraemonSizeFrom750_Landscape
(
60
),
kDoraemonSizeFrom750_Landscape
(
60
));
[
closeBtn
addTarget
:
self
action
:
@selector
(
closeBtnClick
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
closeBtn
];
_oscillogramView
=
[[
DoraemonOscillogramView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
titleLabel
.
doraemon_bottom
+
kDoraemonSizeFrom750_Landscape
(
24
),
(
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
),
kDoraemonSizeFrom750_Landscape
(
400
))];
_oscillogramView
.
backgroundColor
=
[
UIColor
clearColor
];
[
_oscillogramView
setLowValue
:
@"0"
];
[
_oscillogramView
setHightValue
:[
NSString
stringWithFormat
:
@"%zi"
,[
self
deviceMemory
]]];
[
self
.
view
addSubview
:
_oscillogramView
];
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveMemorySwitch
:
NO
];
[[
DoraemonMemoryOscillogramWindow
shareInstance
]
hide
];
-
(
NSString
*
)
title
{
return
DoraemonLocalizedString
(
@"内存检测"
);
}
-
(
NSString
*
)
lowValue
{
return
@"0"
;
}
-
(
void
)
startRecord
{
if
(
!
_secondTimer
){
_secondTimer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
f
target
:
self
selector
:
@selector
(
doSecondFunction
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
currentRunLoop
]
addTimer
:
_secondTimer
forMode
:
NSRunLoopCommonModes
];
}
-
(
NSString
*
)
highValue
{
return
[
NSString
stringWithFormat
:
@"%zi"
,[
self
deviceMemory
]];
}
-
(
void
)
endRecord
{
if
(
_secondTimer
){
[
_secondTimer
invalidate
];
_secondTimer
=
nil
;
[
_oscillogramView
clear
];
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveMemorySwitch
:
NO
];
[[
DoraemonMemoryOscillogramWindow
shareInstance
]
hide
];
}
//每一秒钟采样一次内存使用率
...
...
@@ -79,7 +46,7 @@
NSUInteger
totalMemoryForDevice
=
[
self
deviceMemory
];
// 0~totalMemoryForDevice 对应 高度0~_oscillogramView.doraemon_height
[
_oscillogramView
addHeightValue
:
useMemoryForApp
*
_
oscillogramView
.
doraemon_height
/
totalMemoryForDevice
andTipValue
:[
NSString
stringWithFormat
:
@"%zi"
,
useMemoryForApp
]];
[
self
.
oscillogramView
addHeightValue
:
useMemoryForApp
*
self
.
oscillogramView
.
doraemon_height
/
totalMemoryForDevice
andTipValue
:[
NSString
stringWithFormat
:
@"%zi"
,
useMemoryForApp
]];
}
-
(
NSUInteger
)
deviceMemory
{
...
...
iOS/DoraemonKit/Src/Core/Plugin/NetFlow/Function/View/DoraemonNetFlowOscillogramViewController.m
浏览文件 @
5f6d8e36
...
...
@@ -14,61 +14,29 @@
@interface
DoraemonNetFlowOscillogramViewController
()
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
//每秒运行一次
@property
(
nonatomic
,
strong
)
NSTimer
*
secondTimer
;
@end
@implementation
DoraemonNetFlowOscillogramViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
UILabel
*
titleLabel
=
[[
UILabel
alloc
]
init
];
titleLabel
.
backgroundColor
=
[
UIColor
clearColor
];
titleLabel
.
text
=
DoraemonLocalizedString
(
@"流量检测"
);
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
20
)];
titleLabel
.
textColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
titleLabel
];
[
titleLabel
sizeToFit
];
titleLabel
.
frame
=
CGRectMake
(
kDoraemonSizeFrom750_Landscape
(
20
),
IPHONE_TOPSENSOR_HEIGHT
+
kDoraemonSizeFrom750_Landscape
(
10
),
titleLabel
.
doraemon_width
,
titleLabel
.
doraemon_height
);
UIButton
*
closeBtn
=
[[
UIButton
alloc
]
init
];
[
closeBtn
setImage
:[
UIImage
doraemon_imageNamed
:
@"doraemon_close_white"
]
forState
:
UIControlStateNormal
];
closeBtn
.
frame
=
CGRectMake
((
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
)
-
kDoraemonSizeFrom750_Landscape
(
60
),
IPHONE_TOPSENSOR_HEIGHT
,
kDoraemonSizeFrom750_Landscape
(
60
),
kDoraemonSizeFrom750_Landscape
(
60
));
[
closeBtn
addTarget
:
self
action
:
@selector
(
closeBtnClick
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
view
addSubview
:
closeBtn
];
_oscillogramView
=
[[
DoraemonOscillogramView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
titleLabel
.
doraemon_bottom
+
kDoraemonSizeFrom750_Landscape
(
24
),
(
kInterfaceOrientationPortrait
?
DoraemonScreenWidth
:
DoraemonScreenHeight
),
kDoraemonSizeFrom750_Landscape
(
400
))];
_oscillogramView
.
backgroundColor
=
[
UIColor
clearColor
];
[
_oscillogramView
setLowValue
:
@"0"
];
[
_oscillogramView
setHightValue
:[
NSString
stringWithFormat
:
@"%zi"
,[
self
highestNetFlow
]]];
[
self
.
view
addSubview
:
_oscillogramView
];
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveNetFlowSwitch
:
NO
];
[[
DoraemonNetFlowOscillogramWindow
shareInstance
]
hide
];
-
(
NSString
*
)
title
{
return
DoraemonLocalizedString
(
@"流量检测"
);
}
-
(
NSString
*
)
lowValue
{
return
@"0"
;
}
-
(
void
)
startRecord
{
if
(
!
_secondTimer
){
_secondTimer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
f
target
:
self
selector
:
@selector
(
doSecondFunction
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
currentRunLoop
]
addTimer
:
_secondTimer
forMode
:
NSRunLoopCommonModes
];
}
-
(
NSString
*
)
highValue
{
return
[
NSString
stringWithFormat
:
@"%zi"
,[
self
highestNetFlow
]];
}
-
(
void
)
endRecord
{
if
(
_secondTimer
){
[
_secondTimer
invalidate
];
_secondTimer
=
nil
;
[
_oscillogramView
clear
];
}
-
(
void
)
closeBtnClick
{
[[
DoraemonCacheManager
sharedInstance
]
saveNetFlowSwitch
:
NO
];
[[
DoraemonNetFlowOscillogramWindow
shareInstance
]
hide
];
}
//每一秒钟采样一次流量情况
...
...
@@ -96,7 +64,7 @@
useNetFlowForApp
=
totalNetFlow
;
// 0~highestNetFlow 对应 高度0~200
[
_oscillogramView
addHeightValue
:
useNetFlowForApp
*
_
oscillogramView
.
doraemon_height
/
totalNetFlowForDevice
andTipValue
:[
NSString
stringWithFormat
:
@"%ziB"
,
useNetFlowForApp
]];
[
self
.
oscillogramView
addHeightValue
:
useNetFlowForApp
*
self
.
oscillogramView
.
doraemon_height
/
totalNetFlowForDevice
andTipValue
:[
NSString
stringWithFormat
:
@"%ziB"
,
useNetFlowForApp
]];
}
-
(
NSUInteger
)
highestNetFlow
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录