Skip to content

Commit

Permalink
DoraemonAllTestManager 输出的log文件中的时间戳改为格式化后的字符串,提高可读性
Browse files Browse the repository at this point in the history
  • Loading branch information
cd5z committed Aug 17, 2019
1 parent 9046c71 commit 4f2a9b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ - (void)installWithCustomBlock:(void(^)(void))customBlock{
self.performanceBlock(upLoadData);
}
//默认实现 保存到沙盒中
NSString *testTime = [DoraemonUtil dateFormatTimeInterval:[upLoadData[@"testTime"] floatValue]];
NSString *testTimeString = upLoadData[@"testTime"];

NSString *data = [DoraemonUtil dictToJsonStr:upLoadData];
[DoraemonUtil savePerformanceDataInFile:testTime data:data];
[DoraemonUtil savePerformanceDataInFile:testTimeString data:data];
}];

[[DoraemonANRManager sharedInstance] addANRBlock:^(NSDictionary *anrInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef void (^DoraemonAllTestManagerBlock)(NSDictionary *upLoadData);

+ (DoraemonAllTestManager *)shareInstance;

@property (nonatomic, assign) NSTimeInterval startTimeInterval;
@property (nonatomic, strong) NSDate *startTime;

@property (nonatomic, assign) BOOL fpsSwitchOn;
@property (nonatomic, assign) BOOL cpuSwitchOn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ @interface DoraemonAllTestManager()

@property (nonatomic, copy) DoraemonAllTestManagerBlock block;

@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@end

@implementation DoraemonAllTestManager
Expand All @@ -39,8 +40,16 @@ + (DoraemonAllTestManager *)shareInstance{
return instance;
}

- (NSDateFormatter *)dateFormatter {
if (!_dateFormatter) {
_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss:SSS"];
}
return _dateFormatter;
}

- (void)startRecord{
[DoraemonAllTestManager shareInstance].startTimeInterval = [[NSDate date] timeIntervalSince1970];
[DoraemonAllTestManager shareInstance].startTime = [NSDate date];
if(!_secondTimer){
_secondTimer = [NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(doSecondFunction) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_secondTimer forMode:NSRunLoopCommonModes];
Expand All @@ -61,7 +70,7 @@ - (void)startRecord{
}

- (void)upLoadData{
NSString *testTime = [NSString stringWithFormat:@"%f",_startTimeInterval];;
NSString *testTime = [self.dateFormatter stringFromDate: self.startTime];
NSString *phoneName = [DoraemonAppInfoUtil iphoneType];
NSString *phoneSystem = [[UIDevice currentDevice] systemVersion];
NSUInteger totalMemory = [DoraemonMemoryUtil totalMemoryForDevice];
Expand All @@ -78,7 +87,7 @@ - (void)upLoadData{
NSMutableArray *flowData = [NSMutableArray array];
for (DoraemonNetFlowHttpModel *httpModel in httpModelArray) {
NSString *url = httpModel.url;
NSString *time = [NSString stringWithFormat:@"%f",httpModel.startTime];
NSString *time = [self.dateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: httpModel.startTime]];

NSString *upFlow = httpModel.uploadFlow;
NSString *downFlow = httpModel.downFlow;
Expand Down Expand Up @@ -129,9 +138,8 @@ - (void)endRecord{
}

- (void)doSecondFunction{
//1、获取当前时间戳
NSDate *now = [NSDate date];
NSString *timeInterval = [NSString stringWithFormat:@"%f",[now timeIntervalSince1970]];
//1、获取当前时间
NSString *timeString = [self.dateFormatter stringFromDate: [NSDate date]];

//2、获取当前FPS值
NSInteger fpsValue = -1;
Expand Down Expand Up @@ -162,7 +170,7 @@ - (void)doSecondFunction{

//6、组装commonData数据
NSDictionary *commonItemData = @{
@"time":timeInterval,
@"time":timeString,
@"fps":@(fpsValue),
@"CPU":@(cpuValue),
@"memory":@(memoryValue)
Expand Down

0 comments on commit 4f2a9b2

Please sign in to comment.