提交 711ed096 编写于 作者: Y yixiangboy

time profiler ui

上级 3838a049
//
// 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
//
// 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
//
// 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
//
// 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\nsdk过滤了代码调用层次>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
......@@ -49,6 +49,7 @@ static NSTimeInterval stopTime;
+ (void)stopRecord {
doraemon_hook_end();
stopTime = [NSDate new].timeIntervalSince1970;
[self printRecords];
}
+ (void)clearRecords {
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册