Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
d327e367
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
d327e367
编写于
5月 09, 2019
作者:
Y
yixiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fps的计算聚合到DoraemonFPSUtil这个类中
上级
ee00359c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
126 addition
and
68 deletion
+126
-68
iOS/DoraemonKit/Src/Core/Plugin/AllTest/Function/DoraemonAllTestManager.m
...Src/Core/Plugin/AllTest/Function/DoraemonAllTestManager.m
+11
-31
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSOscillogramViewController.m
...lugin/FPS/Function/DoraemonFPSOscillogramViewController.m
+14
-37
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.h
...oraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.h
+22
-0
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.m
...oraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.m
+79
-0
未找到文件。
iOS/DoraemonKit/Src/Core/Plugin/AllTest/Function/DoraemonAllTestManager.m
浏览文件 @
d327e367
...
...
@@ -12,16 +12,15 @@
#import "DoraemonMemoryUtil.h"
#import "DoraemonNetFlowManager.h"
#import "DoraemonNetFlowDataSource.h"
#import "DoraemonFPSUtil.h"
@interface
DoraemonAllTestManager
()
//每秒运行一次
@property
(
nonatomic
,
strong
)
NSTimer
*
secondTimer
;
@property
(
nonatomic
,
strong
)
CADisplayLink
*
link
;
@property
(
nonatomic
,
assign
)
NSUInteger
count
;
@property
(
nonatomic
,
assign
)
NSTimeInterval
lastTime
;
@property
(
nonatomic
,
assign
)
NSInteger
fpsValue
;
@property
(
nonatomic
,
strong
)
DoraemonFPSUtil
*
fpsUtil
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
commonDataArray
;
...
...
@@ -46,12 +45,14 @@
_secondTimer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
f
target
:
self
selector
:
@selector
(
doSecondFunction
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
currentRunLoop
]
addTimer
:
_secondTimer
forMode
:
NSRunLoopCommonModes
];
if
(
_fpsSwitchOn
){
if
(
_link
)
{
_link
.
paused
=
NO
;
}
else
{
_link
=
[
CADisplayLink
displayLinkWithTarget
:
self
selector
:
@selector
(
trigger
:
)];
[
_link
addToRunLoop
:[
NSRunLoop
mainRunLoop
]
forMode
:
NSRunLoopCommonModes
];
if
(
!
_fpsUtil
)
{
_fpsUtil
=
[[
DoraemonFPSUtil
alloc
]
init
];
__weak
typeof
(
self
)
weakSelf
=
self
;
[
_fpsUtil
addFPSBlock
:
^
(
NSInteger
fps
)
{
weakSelf
.
fpsValue
=
fps
;
}];
}
[
_fpsUtil
start
];
}
}
if
(
_flowSwitchOn
){
...
...
@@ -114,12 +115,8 @@
[
_secondTimer
invalidate
];
_secondTimer
=
nil
;
}
if
(
_link
)
{
_link
.
paused
=
YES
;
[
_link
invalidate
];
_link
=
nil
;
_lastTime
=
0
;
_count
=
0
;
if
(
_fpsUtil
)
{
[
_fpsUtil
end
];
}
[
self
upLoadData
];
...
...
@@ -130,23 +127,6 @@
}
-
(
void
)
trigger
:(
CADisplayLink
*
)
link
{
if
(
_lastTime
==
0
)
{
_lastTime
=
link
.
timestamp
;
return
;
}
_count
++
;
NSTimeInterval
delta
=
link
.
timestamp
-
_lastTime
;
if
(
delta
<
1
)
return
;
_lastTime
=
link
.
timestamp
;
CGFloat
fps
=
_count
/
delta
;
_count
=
0
;
NSInteger
intFps
=
(
NSInteger
)(
fps
+
0
.
5
);
_fpsValue
=
intFps
;
}
-
(
void
)
doSecondFunction
{
//1、获取当前时间戳
NSDate
*
now
=
[
NSDate
date
];
...
...
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSOscillogramViewController.m
浏览文件 @
d327e367
...
...
@@ -10,14 +10,13 @@
#import "DoraemonDefine.h"
#import "DoraemonCacheManager.h"
#import "DoraemonFPSOscillogramWindow.h"
#import "DoraemonFPSUtil.h"
@interface
DoraemonFPSOscillogramViewController
()
@property
(
nonatomic
,
strong
)
DoraemonOscillogramView
*
oscillogramView
;
@property
(
nonatomic
,
strong
)
CADisplayLink
*
link
;
@property
(
nonatomic
,
assign
)
NSUInteger
count
;
@property
(
nonatomic
,
assign
)
NSTimeInterval
lastTime
;
@property
(
nonatomic
,
strong
)
DoraemonFPSUtil
*
fpsUtil
;
@end
...
...
@@ -26,6 +25,7 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setEdgesForExtendedLayout
:
UIRectEdgeNone
];
...
...
@@ -58,46 +58,23 @@
[[
DoraemonFPSOscillogramWindow
shareInstance
]
hide
];
}
-
(
void
)
trigger
:(
CADisplayLink
*
)
link
{
if
(
_lastTime
==
0
)
{
_lastTime
=
link
.
timestamp
;
return
;
}
_count
++
;
NSTimeInterval
delta
=
link
.
timestamp
-
_lastTime
;
if
(
delta
<
1
)
return
;
_lastTime
=
link
.
timestamp
;
CGFloat
fps
=
_count
/
delta
;
_count
=
0
;
NSInteger
intFps
=
(
NSInteger
)(
fps
+
0
.
5
);
// 0~60 对应 高度0~_oscillogramView.doraemon_height
[
_oscillogramView
addHeightValue
:
fps
*
_oscillogramView
.
doraemon_height
/
60
.
andTipValue
:[
NSString
stringWithFormat
:
@"%zi"
,
intFps
]];
}
-
(
void
)
startRecord
{
if
(
_link
)
{
_link
.
paused
=
NO
;
}
else
{
_link
=
[
CADisplayLink
displayLinkWithTarget
:
self
selector
:
@selector
(
trigger
:
)];
[
_link
addToRunLoop
:[
NSRunLoop
mainRunLoop
]
forMode
:
NSRunLoopCommonModes
];
if
(
!
_fpsUtil
)
{
_fpsUtil
=
[[
DoraemonFPSUtil
alloc
]
init
];
__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
]];
}];
}
[
_fpsUtil
start
];
}
-
(
void
)
endRecord
{
if
(
_link
)
{
_link
.
paused
=
YES
;
[
_link
invalidate
];
_link
=
nil
;
[
_oscillogramView
clear
];
_lastTime
=
0
;
_count
=
0
;
if
(
_fpsUtil
)
{
[
_fpsUtil
end
];
}
}
-
(
void
)
addRecortArray
:(
NSArray
*
)
recordArray
{
[
_oscillogramView
addRecortArray
:
recordArray
];
[
_oscillogramView
clear
];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.h
0 → 100644
浏览文件 @
d327e367
//
// DoraemonFPSUtil.h
// AFNetworking
//
// Created by yixiang on 2019/5/9.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef
void
(
^
DoraemonFPSBlock
)(
NSInteger
fps
);
@interface
DoraemonFPSUtil
:
NSObject
-
(
void
)
start
;
-
(
void
)
end
;
-
(
void
)
addFPSBlock
:(
DoraemonFPSBlock
)
block
;
@end
NS_ASSUME_NONNULL_END
iOS/DoraemonKit/Src/Core/Plugin/FPS/Function/DoraemonFPSUtil.m
0 → 100644
浏览文件 @
d327e367
//
// DoraemonFPSUtil.m
// AFNetworking
//
// Created by yixiang on 2019/5/9.
//
#import "DoraemonFPSUtil.h"
@interface
DoraemonFPSUtil
()
@property
(
nonatomic
,
strong
)
CADisplayLink
*
link
;
@property
(
nonatomic
,
assign
)
NSUInteger
count
;
@property
(
nonatomic
,
assign
)
NSTimeInterval
lastTime
;
@property
(
nonatomic
,
assign
)
BOOL
isStart
;
@property
(
nonatomic
,
assign
)
NSInteger
fps
;
@property
(
nonatomic
,
copy
)
DoraemonFPSBlock
block
;
@end
@implementation
DoraemonFPSUtil
-
(
instancetype
)
init
{
self
=
[
super
init
];
if
(
self
)
{
_isStart
=
NO
;
_count
=
0
;
_lastTime
=
0
;
}
return
self
;
}
-
(
void
)
start
{
if
(
_link
)
{
_link
.
paused
=
NO
;
}
else
{
_link
=
[
CADisplayLink
displayLinkWithTarget
:
self
selector
:
@selector
(
trigger
:
)];
[
_link
addToRunLoop
:[
NSRunLoop
mainRunLoop
]
forMode
:
NSRunLoopCommonModes
];
}
}
-
(
void
)
end
{
if
(
_link
)
{
_link
.
paused
=
YES
;
[
_link
invalidate
];
_link
=
nil
;
_lastTime
=
0
;
_count
=
0
;
}
}
-
(
void
)
trigger
:(
CADisplayLink
*
)
link
{
if
(
_lastTime
==
0
)
{
_lastTime
=
link
.
timestamp
;
return
;
}
_count
++
;
NSTimeInterval
delta
=
link
.
timestamp
-
_lastTime
;
if
(
delta
<
1
)
return
;
_lastTime
=
link
.
timestamp
;
CGFloat
fps
=
_count
/
delta
;
_count
=
0
;
NSInteger
intFps
=
(
NSInteger
)(
fps
+
0
.
5
);
self
.
fps
=
intFps
;
if
(
self
.
block
)
{
self
.
block
(
self
.
fps
);
}
}
-
(
void
)
addFPSBlock
:(
void
(
^
)(
NSInteger
fps
))
block
{
self
.
block
=
block
;
}
-
(
void
)
dealloc
{
NSLog
(
@"fps dealloc"
);
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录