Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
711ed096
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
711ed096
编写于
10月 15, 2019
作者:
Y
yixiangboy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
time profiler ui
上级
3838a049
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
1 deletion
+101
-1
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.h
...Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.h
+17
-0
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.m
...Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.m
+19
-0
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerViewController.h
.../Plugin/TimeProfiler/DoraemonTimeProfilerViewController.h
+17
-0
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerViewController.m
.../Plugin/TimeProfiler/DoraemonTimeProfilerViewController.m
+47
-0
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/Function/DoraemonTimeProfiler.m
.../Core/Plugin/TimeProfiler/Function/DoraemonTimeProfiler.m
+1
-0
iOS/DoraemonKitDemo/DoraemonKitDemo/DoKitAppDelegate.m
iOS/DoraemonKitDemo/DoraemonKitDemo/DoKitAppDelegate.m
+0
-1
未找到文件。
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.h
0 → 100644
浏览文件 @
711ed096
//
// DoraemonTimeProfilerPlugin.h
// AFNetworking
//
// Created by didi on 2019/10/15.
//
#import <Foundation/Foundation.h>
#import "DoraemonPluginProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface
DoraemonTimeProfilerPlugin
:
NSObject
<
DoraemonPluginProtocol
>
@end
NS_ASSUME_NONNULL_END
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerPlugin.m
0 → 100644
浏览文件 @
711ed096
//
// DoraemonTimeProfilerPlugin.m
// AFNetworking
//
// Created by didi on 2019/10/15.
//
#import "DoraemonTimeProfilerPlugin.h"
#import "DoraemonUtil.h"
#import "DoraemonTimeProfilerViewController.h"
@implementation
DoraemonTimeProfilerPlugin
-
(
void
)
pluginDidLoad
{
DoraemonTimeProfilerViewController
*
vc
=
[[
DoraemonTimeProfilerViewController
alloc
]
init
];
[
DoraemonUtil
openPlugin
:
vc
];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerViewController.h
0 → 100644
浏览文件 @
711ed096
//
// DoraemonTimeProfilerViewController.h
// AFNetworking
//
// Created by didi on 2019/10/15.
//
#import <UIKit/UIKit.h>
#import "DoraemonBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface
DoraemonTimeProfilerViewController
:
DoraemonBaseViewController
@end
NS_ASSUME_NONNULL_END
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/DoraemonTimeProfilerViewController.m
0 → 100644
浏览文件 @
711ed096
//
// DoraemonTimeProfilerViewController.m
// AFNetworking
//
// Created by didi on 2019/10/15.
//
#import "DoraemonTimeProfilerViewController.h"
#import "DoraemonDefine.h"
@interface
DoraemonTimeProfilerViewController
()
@property
(
nonatomic
,
strong
)
UILabel
*
contentLabel
;
@end
@implementation
DoraemonTimeProfilerViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
title
=
@"函数耗时"
;
NSString
*
contet
=
@"
\n\n\n
函数不提供UI操作界面,在你需要分析的代码之前插入
\n\n
[DoraemonTimeProfiler startRecord];
\n\n
结束的地方加上
\n\n
[DoraemonTimeProfiler stopRecord];
\n\n
然后手动操作App执行代码流程,即可在控制台看到完整的函数耗时分析。
\n\n
sdk过滤了代码调用层次>10层,耗时小于1ms的函数调用,当然你也可以通过api自行设置。
\n\n
分析完毕之后,记得删掉startRecord和stopRecord的函数调用。"
;
_contentLabel
=
[[
UILabel
alloc
]
init
];
_contentLabel
.
textColor
=
[
UIColor
doraemon_black_2
];
_contentLabel
.
font
=
[
UIFont
systemFontOfSize
:
kDoraemonSizeFrom750_Landscape
(
24
)];
_contentLabel
.
numberOfLines
=
0
;
[
self
.
view
addSubview
:
_contentLabel
];
NSMutableAttributedString
*
attrStr
=
[[
NSMutableAttributedString
alloc
]
initWithString
:
contet
];
NSRange
range
=
[
contet
rangeOfString
:
@"[DoraemonTimeProfiler startRecord];"
];
[
attrStr
addAttribute
:
NSForegroundColorAttributeName
value
:[
UIColor
redColor
]
range
:
range
];
range
=
[
contet
rangeOfString
:
@"[DoraemonTimeProfiler stopRecord];"
];
[
attrStr
addAttribute
:
NSForegroundColorAttributeName
value
:[
UIColor
redColor
]
range
:
range
];
range
=
[
contet
rangeOfString
:
@"分析完毕之后,记得删掉startRecord和stopRecord的函数调用。"
];
[
attrStr
addAttribute
:
NSForegroundColorAttributeName
value
:[
UIColor
redColor
]
range
:
range
];
_contentLabel
.
attributedText
=
attrStr
;
CGSize
fontSize
=
[
_contentLabel
sizeThatFits
:
CGSizeMake
(
self
.
view
.
doraemon_width
-
40
,
MAXFLOAT
)];
_contentLabel
.
frame
=
CGRectMake
(
20
,
self
.
bigTitleView
.
doraemon_bottom
,
fontSize
.
width
,
fontSize
.
height
);
}
-
(
BOOL
)
needBigTitleView
{
return
YES
;
}
@end
iOS/DoraemonKit/Src/Core/Plugin/TimeProfiler/Function/DoraemonTimeProfiler.m
浏览文件 @
711ed096
...
...
@@ -49,6 +49,7 @@ static NSTimeInterval stopTime;
+
(
void
)
stopRecord
{
doraemon_hook_end
();
stopTime
=
[
NSDate
new
].
timeIntervalSince1970
;
[
self
printRecords
];
}
+
(
void
)
clearRecords
{
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DoKitAppDelegate.m
浏览文件 @
711ed096
...
...
@@ -69,7 +69,6 @@
NSLog
(
@"%@"
,[
array
description
]);
//[DoraemonTimeProfiler stopRecord];
//[DoraemonTimeProfiler printRecords];
return
YES
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录