2019-10-16 20:03:47 +03:00
|
|
|
/*
|
2018-09-12 01:27:47 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-06-20 00:59:42 +03:00
|
|
|
*
|
2018-02-17 05:24:55 +03:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-06-20 00:59:42 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2019-05-18 18:23:37 +03:00
|
|
|
// Keep this in sync with _labelsForTags
|
2015-06-20 00:59:42 +03:00
|
|
|
typedef NS_ENUM(NSUInteger, RCTPLTag) {
|
|
|
|
RCTPLScriptDownload = 0,
|
2015-08-21 21:33:04 +03:00
|
|
|
RCTPLScriptExecution,
|
2016-04-01 17:24:40 +03:00
|
|
|
RCTPLRAMBundleLoad,
|
|
|
|
RCTPLRAMStartupCodeSize,
|
2016-09-10 01:22:20 +03:00
|
|
|
RCTPLRAMStartupNativeRequires,
|
|
|
|
RCTPLRAMStartupNativeRequiresCount,
|
2016-04-01 21:08:19 +03:00
|
|
|
RCTPLRAMNativeRequires,
|
2016-04-01 17:24:40 +03:00
|
|
|
RCTPLRAMNativeRequiresCount,
|
2015-08-21 21:33:04 +03:00
|
|
|
RCTPLNativeModuleInit,
|
2016-03-15 15:40:09 +03:00
|
|
|
RCTPLNativeModuleMainThread,
|
2015-10-08 18:41:55 +03:00
|
|
|
RCTPLNativeModulePrepareConfig,
|
2016-03-16 19:46:55 +03:00
|
|
|
RCTPLNativeModuleMainThreadUsesCount,
|
2019-03-22 20:39:38 +03:00
|
|
|
RCTPLNativeModuleSetup,
|
2019-05-16 01:24:53 +03:00
|
|
|
RCTPLTurboModuleSetup,
|
2016-05-31 22:50:48 +03:00
|
|
|
RCTPLJSCWrapperOpenLibrary,
|
2016-04-01 17:24:40 +03:00
|
|
|
RCTPLBridgeStartup,
|
2015-06-20 00:59:42 +03:00
|
|
|
RCTPLTTI,
|
2015-10-21 20:53:35 +03:00
|
|
|
RCTPLBundleSize,
|
2020-10-31 00:02:05 +03:00
|
|
|
RCTPLReactInstanceInit,
|
2019-05-18 18:23:37 +03:00
|
|
|
RCTPLSize // This is used to count the size
|
2015-06-20 00:59:42 +03:00
|
|
|
};
|
|
|
|
|
2016-07-07 17:20:03 +03:00
|
|
|
@interface RCTPerformanceLogger : NSObject
|
|
|
|
|
2016-03-15 15:40:09 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
2016-07-07 17:20:03 +03:00
|
|
|
* All work is scheduled on the background queue so this doesn't block current thread.
|
2016-03-15 15:40:09 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (void)markStartForTag:(RCTPLTag)tag;
|
2016-03-15 15:40:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2016-07-07 17:20:03 +03:00
|
|
|
* All work is scheduled on the background queue so this doesn't block current thread.
|
2016-03-15 15:40:09 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (void)markStopForTag:(RCTPLTag)tag;
|
2016-03-15 15:40:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets given value for a metric with given tag.
|
2016-07-07 17:20:03 +03:00
|
|
|
* All work is scheduled on the background queue so this doesn't block current thread.
|
2016-03-15 15:40:09 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (void)setValue:(int64_t)value forTag:(RCTPLTag)tag;
|
2016-03-15 15:40:09 +03:00
|
|
|
|
2016-04-01 17:24:40 +03:00
|
|
|
/**
|
|
|
|
* Adds given value to the current value for a metric with given tag.
|
2016-07-07 17:20:03 +03:00
|
|
|
* All work is scheduled on the background queue so this doesn't block current thread.
|
2016-04-01 17:24:40 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (void)addValue:(int64_t)value forTag:(RCTPLTag)tag;
|
2016-04-01 17:24:40 +03:00
|
|
|
|
2016-03-15 15:40:09 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
2016-07-07 17:20:03 +03:00
|
|
|
* All work is scheduled on the background queue so this doesn't block current thread.
|
2016-03-15 15:40:09 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (void)appendStartForTag:(RCTPLTag)tag;
|
2016-03-15 15:40:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2016-07-07 17:20:03 +03:00
|
|
|
* 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;
|
|
|
|
|
|
|
|
/**
|
2016-07-22 19:50:48 +03:00
|
|
|
* Returns a duration in ms (stop_time - start_time) for given RCTPLTag.
|
2016-07-07 17:20:03 +03:00
|
|
|
*/
|
|
|
|
- (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.
|
2016-03-15 15:40:09 +03:00
|
|
|
*/
|
2016-07-07 17:20:03 +03:00
|
|
|
- (NSArray<NSString *> *)labelsForTags;
|
2016-03-15 15:40:09 +03:00
|
|
|
|
2016-07-07 17:20:03 +03:00
|
|
|
@end
|