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:
Mike Armstrong
2015-11-25 00:49:17 -08:00
committed by facebook-github-bot-8
parent e6897dd9b3
commit aaffb239ca

View File

@@ -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);
}