RCTPerformanceLogger.h
3.19 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLScriptDownload = 0,
RCTPLScriptExecution,
RCTPLRAMBundleLoad,
RCTPLRAMStartupCodeSize,
RCTPLRAMStartupNativeRequires,
RCTPLRAMStartupNativeRequiresCount,
RCTPLRAMNativeRequires,
RCTPLRAMNativeRequiresCount,
RCTPLNativeModuleInit,
RCTPLNativeModuleMainThread,
RCTPLNativeModulePrepareConfig,
RCTPLNativeModuleInjectConfig,
RCTPLNativeModuleMainThreadUsesCount,
RCTPLJSCWrapperOpenLibrary,
RCTPLJSCExecutorSetup,
RCTPLBridgeStartup,
RCTPLTTI,
RCTPLBundleSize,
RCTPLSize
};
@interface RCTPerformanceLogger : NSObject
/**
* Starts measuring a metric with the given tag.
* Overrides previous value if the measurement has been already started.
* If RCTProfile is enabled it also begins appropriate async event.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)markStartForTag:(RCTPLTag)tag;
/**
* Stops measuring a metric with given tag.
* Checks if RCTPerformanceLoggerStart() has been called before
* and doesn't do anything and log a message if it hasn't.
* If RCTProfile is enabled it also ends appropriate async event.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)markStopForTag:(RCTPLTag)tag;
/**
* Sets given value for a metric with given tag.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)setValue:(int64_t)value forTag:(RCTPLTag)tag;
/**
* Adds given value to the current value for a metric with given tag.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)addValue:(int64_t)value forTag:(RCTPLTag)tag;
/**
* Starts an additional measurement for a metric with given tag.
* It doesn't override previous measurement, instead it'll append a new value
* to the old one.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)appendStartForTag:(RCTPLTag)tag;
/**
* Stops measurement and appends the result to the metric with given tag.
* Checks if RCTPerformanceLoggerAppendStart() has been called before
* and doesn't do anything and log a message if it hasn't.
* All work is scheduled on the background queue so this doesn't block current thread.
*/
- (void)appendStopForTag:(RCTPLTag)tag;
/**
* Returns an array with values for all tags.
* Use RCTPLTag to go over the array, there's a pair of values
* for each tag: start and stop (with indexes 2 * tag and 2 * tag + 1).
*/
- (NSArray<NSNumber *> *)valuesForTags;
/**
* Returns a duration in ms (stop_time - start_time) for given RCTPLTag.
*/
- (int64_t)durationForTag:(RCTPLTag)tag;
/**
* Returns a value for given RCTPLTag.
*/
- (int64_t)valueForTag:(RCTPLTag)tag;
/**
* Returns an array with values for all tags.
* Use RCTPLTag to go over the array.
*/
- (NSArray<NSString *> *)labelsForTags;
@end