Authored by 郁健超

移除SDWebImage中性能分析

... ... @@ -8,7 +8,6 @@
#import "SDWebImageDownloaderOperation+Performance.h"
#import "Aspects.h"
#import "YH_Analytics.h"
@implementation SDWebImageDownloaderOperation (Performance)
... ... @@ -23,14 +22,7 @@
// finish
[SDWebImageDownloaderOperation aspect_hookSelector:@selector(operationDidFinish) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo>aspectInfo){
SDWebImageDownloaderOperation *op = [aspectInfo instance];
NSTimeInterval currentTS = [[NSDate date]timeIntervalSince1970];
NSInteger status = -1;
long deltaTS = (currentTS - op.begainLoadImageTimestamp) * 1000;
NSString *url = [SDWebImageDownloaderOperation urlWithOperation:op];
NSString *opAddr = [NSString stringWithFormat:@"%p", op];
if (op.response) {
if ([op.response isKindOfClass:[NSHTTPURLResponse class]]) {
NSHTTPURLResponse *response = (NSHTTPURLResponse *)op.response;
... ... @@ -40,14 +32,6 @@
// success
status = 1;
}
[[YH_Analytics sharedInstance]logPerformanceWithType:kPerformanceTypeImageLoad
parameters:@{JsonKeyPerformanceEvtEID:opAddr?:@"",
JsonKeyPerformanceURL: url?:@"",
JsonKeyPerformanceTS: @((long)(op.begainLoadImageTimestamp*1000)),
JsonKeyPerformanceCTS:@(deltaTS),
JsonKeyPerformanceSTATUS : @(status)
}];
}
} error:NULL];
... ... @@ -56,25 +40,11 @@
// error
[SDWebImageDownloaderOperation aspect_hookSelector:@selector(operationError:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo>aspectInfo){
SDWebImageDownloaderOperation *op = [aspectInfo instance];
NSTimeInterval currentTS = [[NSDate date]timeIntervalSince1970];
long deltaTS = (currentTS - op.begainLoadImageTimestamp) * 1000;
NSString *url = [SDWebImageDownloaderOperation urlWithOperation:op];
NSString *opAddr = [NSString stringWithFormat:@"%p", op];
// error code default is `-1`
NSInteger errorCode = -1;
if (op.error) {
errorCode = [op.error code];
}
[[YH_Analytics sharedInstance]logPerformanceWithType:kPerformanceTypeImageLoad
parameters:@{JsonKeyPerformanceEvtEID:opAddr?:@"",
JsonKeyPerformanceURL: url?:@"",
JsonKeyPerformanceTS: @((long)(op.begainLoadImageTimestamp*1000)),
JsonKeyPerformanceCTS:@(deltaTS),
JsonKeyPerformanceSTATUS : @(errorCode)
}];
} error:NULL];
// cancel
... ...