mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 09:12:06 +08:00
Allow the output of the JSC profile to be specified in JS
Reviewed By: astreet Differential Revision: D2674869 fb-gh-sync-id: 15e192015ecc9291359d6c988e793849eac97513
This commit is contained in:
committed by
facebook-github-bot-8
parent
e6897dd9b3
commit
aaffb239ca
@@ -7,6 +7,7 @@
|
||||
#include <jsc_legacy_profiler.h>
|
||||
#include "JSCHelpers.h"
|
||||
#include "JSCLegacyProfiler.h"
|
||||
#include "Value.h"
|
||||
|
||||
static JSValueRef nativeProfilerStart(
|
||||
JSContextRef ctx,
|
||||
@@ -20,7 +21,7 @@ static JSValueRef nativeProfilerStart(
|
||||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
JSStringRef title = JSValueToStringCopy(ctx, arguments[0], NULL);
|
||||
JSStringRef title = JSValueToStringCopy(ctx, arguments[0], exception);
|
||||
JSStartProfiling(ctx, title);
|
||||
JSStringRelease(title);
|
||||
return JSValueMakeUndefined(ctx);
|
||||
@@ -38,8 +39,16 @@ static JSValueRef nativeProfilerEnd(
|
||||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
JSStringRef title = JSValueToStringCopy(ctx, arguments[0], NULL);
|
||||
JSEndProfilingAndRender(ctx, title, "/sdcard/profile.json");
|
||||
std::string writeLocation("/sdcard/");
|
||||
if (argumentCount > 1) {
|
||||
JSStringRef fileName = JSValueToStringCopy(ctx, arguments[1], exception);
|
||||
writeLocation += facebook::react::String::ref(fileName).str();
|
||||
JSStringRelease(fileName);
|
||||
} else {
|
||||
writeLocation += "profile.json";
|
||||
}
|
||||
JSStringRef title = JSValueToStringCopy(ctx, arguments[0], exception);
|
||||
JSEndProfilingAndRender(ctx, title, writeLocation.c_str());
|
||||
JSStringRelease(title);
|
||||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user