1 | /*
|
2 | * Copyright (c) Facebook, Inc. and its affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | */
|
7 |
|
8 |
|
9 |
|
10 | // Keep this in sync with _labelsForTags
|
11 | typedef NS_ENUM(NSUInteger, RCTPLTag) {
|
12 | RCTPLScriptDownload = 0,
|
13 | RCTPLScriptExecution,
|
14 | RCTPLRAMBundleLoad,
|
15 | RCTPLRAMStartupCodeSize,
|
16 | RCTPLRAMStartupNativeRequires,
|
17 | RCTPLRAMStartupNativeRequiresCount,
|
18 | RCTPLRAMNativeRequires,
|
19 | RCTPLRAMNativeRequiresCount,
|
20 | RCTPLNativeModuleInit,
|
21 | RCTPLNativeModuleMainThread,
|
22 | RCTPLNativeModulePrepareConfig,
|
23 | RCTPLNativeModuleMainThreadUsesCount,
|
24 | RCTPLNativeModuleSetup,
|
25 | RCTPLTurboModuleSetup,
|
26 | RCTPLJSCWrapperOpenLibrary,
|
27 | RCTPLBridgeStartup,
|
28 | RCTPLTTI,
|
29 | RCTPLBundleSize,
|
30 | RCTPLSize // This is used to count the size
|
31 | };
|
32 |
|
33 | @interface RCTPerformanceLogger : NSObject
|
34 |
|
35 | /**
|
36 | * Starts measuring a metric with the given tag.
|
37 | * Overrides previous value if the measurement has been already started.
|
38 | * If RCTProfile is enabled it also begins appropriate async event.
|
39 | * All work is scheduled on the background queue so this doesn't block current thread.
|
40 | */
|
41 | - (void)markStartForTag:(RCTPLTag)tag;
|
42 |
|
43 | /**
|
44 | * Stops measuring a metric with given tag.
|
45 | * Checks if RCTPerformanceLoggerStart() has been called before
|
46 | * and doesn't do anything and log a message if it hasn't.
|
47 | * If RCTProfile is enabled it also ends appropriate async event.
|
48 | * All work is scheduled on the background queue so this doesn't block current thread.
|
49 | */
|
50 | - (void)markStopForTag:(RCTPLTag)tag;
|
51 |
|
52 | /**
|
53 | * Sets given value for a metric with given tag.
|
54 | * All work is scheduled on the background queue so this doesn't block current thread.
|
55 | */
|
56 | - (void)setValue:(int64_t)value forTag:(RCTPLTag)tag;
|
57 |
|
58 | /**
|
59 | * Adds given value to the current value for a metric with given tag.
|
60 | * All work is scheduled on the background queue so this doesn't block current thread.
|
61 | */
|
62 | - (void)addValue:(int64_t)value forTag:(RCTPLTag)tag;
|
63 |
|
64 | /**
|
65 | * Starts an additional measurement for a metric with given tag.
|
66 | * It doesn't override previous measurement, instead it'll append a new value
|
67 | * to the old one.
|
68 | * All work is scheduled on the background queue so this doesn't block current thread.
|
69 | */
|
70 | - (void)appendStartForTag:(RCTPLTag)tag;
|
71 |
|
72 | /**
|
73 | * Stops measurement and appends the result to the metric with given tag.
|
74 | * Checks if RCTPerformanceLoggerAppendStart() has been called before
|
75 | * and doesn't do anything and log a message if it hasn't.
|
76 | * All work is scheduled on the background queue so this doesn't block current thread.
|
77 | */
|
78 | - (void)appendStopForTag:(RCTPLTag)tag;
|
79 |
|
80 | /**
|
81 | * Returns an array with values for all tags.
|
82 | * Use RCTPLTag to go over the array, there's a pair of values
|
83 | * for each tag: start and stop (with indexes 2 * tag and 2 * tag + 1).
|
84 | */
|
85 | - (NSArray<NSNumber *> *)valuesForTags;
|
86 |
|
87 | /**
|
88 | * Returns a duration in ms (stop_time - start_time) for given RCTPLTag.
|
89 | */
|
90 | - (int64_t)durationForTag:(RCTPLTag)tag;
|
91 |
|
92 | /**
|
93 | * Returns a value for given RCTPLTag.
|
94 | */
|
95 | - (int64_t)valueForTag:(RCTPLTag)tag;
|
96 |
|
97 | /**
|
98 | * Returns an array with values for all tags.
|
99 | * Use RCTPLTag to go over the array.
|
100 | */
|
101 | - (NSArray<NSString *> *)labelsForTags;
|
102 |
|
103 | @end
|