提交 d31c999e 编写于 作者: Y yixiangboy

app launch add time profiler

上级 5ea66e79
......@@ -15,6 +15,7 @@
#import <objc/runtime.h>
#import "DoraemonHealthManager.h"
#import "DoraemonTimeProfiler.h"
#import "DoraemonStartTimeProfilerViewController.h"
static NSTimeInterval startTime;
static NSTimeInterval endTime;
......@@ -92,6 +93,8 @@ static NSTimeInterval endTime;
#pragma mark -- DoraemonCellButtonDelegate
- (void)cellBtnClick:(id)sender{
DoraemonStartTimeProfilerViewController *vc = [[DoraemonStartTimeProfilerViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
......
//
// DoraemonStartTimeProfilerViewController.h
// DoraemonKit-DoraemonKit
//
// Created by didi on 2020/4/13.
//
#import "DoraemonBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonStartTimeProfilerViewController : DoraemonBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonStartTimeProfilerViewController.m
// DoraemonKit-DoraemonKit
//
// Created by didi on 2020/4/13.
//
#import "DoraemonStartTimeProfilerViewController.h"
#import "DoraemonDefine.h"
#import "DoraemonHealthManager.h"
@interface DoraemonStartTimeProfilerViewController ()
@property (nonatomic, strong) UITextView *contentLabel;
@end
@implementation DoraemonStartTimeProfilerViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonLocalizedString(@"启动耗时");
[self setRightNavTitle:DoraemonLocalizedString(@"导出")];
NSString *costDetail = [DoraemonHealthManager sharedInstance].costDetail;
_contentLabel = [[UITextView alloc] initWithFrame:self.view.bounds];
_contentLabel.textColor = [UIColor doraemon_black_2];
_contentLabel.font = [UIFont systemFontOfSize:kDoraemonSizeFrom750_Landscape(16)];
_contentLabel.text = costDetail;
[self.view addSubview:_contentLabel];
}
- (void)rightNavTitleClick:(id)clickView{
[self export:_contentLabel.text];
}
- (void)export:(NSString *)text {
NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
NSString *tempDir = [cachesDir stringByAppendingPathComponent:@"DoKitTemp"];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir = NO;
BOOL existed = [fileManager fileExistsAtPath:tempDir isDirectory:&isDir];
if(!(isDir && existed)){
[fileManager createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:nil];
}
NSString *path = [tempDir stringByAppendingPathComponent:@"startCostDetail.txt"];
BOOL writeSuccess = [text writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
if (writeSuccess) {
[DoraemonUtil shareFileWithPath:path formVC:self];
}
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册