mirror of
https://github.com/status-im/react-native.git
synced 2025-02-03 05:03:42 +00:00
log script name with bundle loading perf event
Reviewed By: javache Differential Revision: D5010638 fbshipit-source-id: 2e139201a8374245fa1dedc4f11a716dcf700fd7
This commit is contained in:
parent
5dcfb2c6ad
commit
65f22a5190
@ -76,7 +76,7 @@ static bool isRAMBundle(NSData *script) {
|
||||
|
||||
static void registerPerformanceLoggerHooks(RCTPerformanceLogger *performanceLogger) {
|
||||
__weak RCTPerformanceLogger *weakPerformanceLogger = performanceLogger;
|
||||
ReactMarker::logMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId) {
|
||||
ReactMarker::logTaggedMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId, const char* tag) {
|
||||
switch (markerId) {
|
||||
case ReactMarker::RUN_JS_BUNDLE_START:
|
||||
[weakPerformanceLogger markStartForTag:RCTPLScriptExecution];
|
||||
|
@ -45,7 +45,7 @@ JSValueRef nativePerformanceNow(
|
||||
}
|
||||
|
||||
void RCTPrepareJSCExecutor() {
|
||||
ReactMarker::logMarker = [](const ReactMarker::ReactMarkerId) {};
|
||||
ReactMarker::logTaggedMarker = [](const ReactMarker::ReactMarkerId, const char* tag) {};
|
||||
PerfLogging::installNativeHooks = RCTFBQuickPerformanceLoggerConfigureHooks;
|
||||
JSNativeHooks::loggingHook = nativeLoggingHook;
|
||||
JSNativeHooks::nowHook = nativePerformanceNow;
|
||||
|
@ -84,11 +84,18 @@ class ProxyJavaScriptExecutorHolder : public HybridClass<ProxyJavaScriptExecutor
|
||||
class JReactMarker : public JavaClass<JReactMarker> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/ReactMarker;";
|
||||
|
||||
static void logMarker(const std::string& marker) {
|
||||
static auto cls = javaClassStatic();
|
||||
static auto meth = cls->getStaticMethod<void(std::string)>("logMarker");
|
||||
meth(cls, marker);
|
||||
}
|
||||
|
||||
static void logMarker(const std::string& marker, const std::string& tag) {
|
||||
static auto cls = javaClassStatic();
|
||||
static auto meth = cls->getStaticMethod<void(std::string, std::string)>("logMarker");
|
||||
meth(cls, marker, tag);
|
||||
}
|
||||
};
|
||||
|
||||
static JSValueRef nativePerformanceNow(
|
||||
@ -113,10 +120,10 @@ static JSValueRef nativePerformanceNow(
|
||||
return Value::makeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
|
||||
}
|
||||
|
||||
static void logPerfMarker(const ReactMarker::ReactMarkerId markerId) {
|
||||
static void logPerfMarker(const ReactMarker::ReactMarkerId markerId, const char* tag) {
|
||||
switch (markerId) {
|
||||
case ReactMarker::RUN_JS_BUNDLE_START:
|
||||
JReactMarker::logMarker("RUN_JS_BUNDLE_START");
|
||||
JReactMarker::logMarker("RUN_JS_BUNDLE_START", tag);
|
||||
break;
|
||||
case ReactMarker::RUN_JS_BUNDLE_STOP:
|
||||
JReactMarker::logMarker("RUN_JS_BUNDLE_END");
|
||||
@ -143,7 +150,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
return initialize(vm, [] {
|
||||
gloginit::initialize();
|
||||
// Inject some behavior into react/
|
||||
ReactMarker::logMarker = logPerfMarker;
|
||||
ReactMarker::logTaggedMarker = logPerfMarker;
|
||||
PerfLogging::installNativeHooks = addNativePerfLoggingHooks;
|
||||
JSNativeHooks::loggingHook = nativeLoggingHook;
|
||||
JSNativeHooks::nowHook = nativePerformanceNow;
|
||||
|
@ -292,11 +292,18 @@ static const char* explainLoadSourceStatus(JSLoadSourceStatus status) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// basename_r isn't in all iOS SDKs, so use this simple version instead.
|
||||
static std::string simpleBasename(const std::string &path) {
|
||||
size_t pos = path.rfind("/");
|
||||
return (pos != std::string::npos) ? path.substr(pos) : path;
|
||||
}
|
||||
|
||||
void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> script, std::string sourceURL) {
|
||||
SystraceSection s("JSCExecutor::loadApplicationScript",
|
||||
"sourceURL", sourceURL);
|
||||
|
||||
ReactMarker::logMarker(ReactMarker::RUN_JS_BUNDLE_START);
|
||||
std::string scriptName = simpleBasename(sourceURL);
|
||||
ReactMarker::logTaggedMarker(ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
|
||||
String jsSourceURL(m_context, sourceURL.c_str());
|
||||
|
||||
// TODO t15069155: reduce the number of overrides here
|
||||
|
@ -6,7 +6,12 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
namespace ReactMarker {
|
||||
LogMarker logMarker;
|
||||
LogTaggedMarker logTaggedMarker;
|
||||
|
||||
void logMarker(const ReactMarkerId markerId) {
|
||||
logTaggedMarker(markerId, nullptr);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
namespace PerfLogging {
|
||||
|
@ -23,8 +23,12 @@ enum ReactMarkerId {
|
||||
JS_BUNDLE_STRING_CONVERT_START,
|
||||
JS_BUNDLE_STRING_CONVERT_STOP,
|
||||
};
|
||||
using LogMarker = std::function<void(const ReactMarkerId)>;
|
||||
extern LogMarker logMarker;
|
||||
|
||||
using LogTaggedMarker = std::function<void(const ReactMarkerId, const char* tag)>;
|
||||
extern LogTaggedMarker logTaggedMarker;
|
||||
|
||||
extern void logMarker(const ReactMarkerId markerId);
|
||||
|
||||
};
|
||||
|
||||
namespace PerfLogging {
|
||||
|
Loading…
x
Reference in New Issue
Block a user