Measure performance for ASCellNode layout (#2209)

* Measure performance for ASCellNode layout

* Address Adlai and Levi's feedback:
* Move to ASDisplayNode level
* Lock around setting/getting measurement options and results
* Record all measurement passes and report times as an array
* Only add relevant entries to the performanceMetrics dictionary
* Rebase

* Store sum and count instead of array

* Rename ScopeTimerDataPoint to ScopeTimerSum

* Address Levi's feedback

* Address Adlai's feedback
This commit is contained in:
Harry Shamansky
2016-09-09 10:38:13 -07:00
committed by Adlai Holler
parent 8c2f3f666f
commit 59fbfb682d
4 changed files with 100 additions and 3 deletions

View File

@@ -18,6 +18,22 @@ void ASPerformBlockOnMainThread(void (^block)());
void ASPerformBlockOnBackgroundThread(void (^block)()); // DISPATCH_QUEUE_PRIORITY_DEFAULT
ASDISPLAYNODE_EXTERN_C_END
/**
* Bitmask to indicate what performance measurements the cell should record.
*/
typedef NS_OPTIONS(NSUInteger, ASDisplayNodePerformanceMeasurementOptions) {
ASDisplayNodePerformanceMeasurementOptionLayoutSpec = 1 << 0,
ASDisplayNodePerformanceMeasurementOptionLayoutGeneration = 1 << 1
};
/**
* Keys to retrieve performance entries from the performance dictionary.
*/
extern NSString *const ASDisplayNodeLayoutSpecTotalTimeKey;
extern NSString *const ASDisplayNodeLayoutSpecNumberOfPassesKey;
extern NSString *const ASDisplayNodeLayoutGenerationTotalTimeKey;
extern NSString *const ASDisplayNodeLayoutGenerationNumberOfPassesKey;
@interface ASDisplayNode (Beta)
/**
@@ -57,6 +73,17 @@ ASDISPLAYNODE_EXTERN_C_END
*/
@property (nonatomic, copy, nullable) ASDisplayNodeContextModifier didDisplayNodeContentWithRenderingContext;
/**
* @abstract A bitmask representing which actions (layout spec, layout generation) should be measured.
*/
@property (nonatomic, assign) ASDisplayNodePerformanceMeasurementOptions measurementOptions;
/**
* @abstract A dictionary representing performance measurements collected.
* @note see the constants above to retrieve relevant performance measurements
*/
@property (nonatomic, strong, readonly) NSDictionary *performanceMeasurements;
/** @name Layout Transitioning */
/**