forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASPerformanceTestContext.h
44 lines (31 loc) · 1.46 KB
/
ASPerformanceTestContext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// ASPerformanceTestContext.h
// Texture
//
// Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import <Foundation/Foundation.h>
#import <XCTest/XCTestAssertionsImpl.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
#define ASXCTAssertRelativePerformanceInRange(test, caseName, min, max) \
_XCTPrimitiveAssertLessThanOrEqual(self, test.results[caseName].relativePerformance, @#caseName, max, @#max);\
_XCTPrimitiveAssertGreaterThanOrEqual(self, test.results[caseName].relativePerformance, @#caseName, min, @#min)
NS_ASSUME_NONNULL_BEGIN
typedef void (^ASTestPerformanceCaseBlock)(NSUInteger i, dispatch_block_t startMeasuring, dispatch_block_t stopMeasuring);
@interface ASPerformanceTestResult : NSObject
@property (nonatomic, readonly) NSTimeInterval timePer1000;
@property (nonatomic, readonly) NSString *caseName;
@property (nonatomic, readonly, getter=isReferenceCase) BOOL referenceCase;
@property (nonatomic, readonly) float relativePerformance;
@property (nonatomic, readonly) NSMutableDictionary *userInfo;
@end
@interface ASPerformanceTestContext : NSObject
/**
* The first case you add here will be considered the reference case.
*/
- (void)addCaseWithName:(NSString *)caseName block:(AS_NOESCAPE ASTestPerformanceCaseBlock)block;
@property (nonatomic, copy, readonly) NSDictionary<NSString *, ASPerformanceTestResult *> *results;
- (BOOL)areAllUserInfosEqual;
@end
NS_ASSUME_NONNULL_END