Support start and stopping systrace from repl

Reviewed By: @jspahrsummers

Differential Revision: D2512911

fb-gh-sync-id: f5441219f9d7063b3602c55efac9f07407e33f56
This commit is contained in:
Tadeu Zagallo 2015-10-12 09:42:21 -07:00 committed by facebook-github-bot-4
parent e48807abfd
commit f7065e5c0a
2 changed files with 6 additions and 9 deletions

View File

@ -889,24 +889,19 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
{
RCTAssertMainThread();
if (![self.bundleURL.scheme isEqualToString:@"http"]) {
RCTLogError(@"To run the profiler you must be running from the dev server");
return;
}
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
RCTProfileInit(self);
}];
}
- (void)stopProfiling
- (void)stopProfiling:(void (^)(NSData *))callback
{
RCTAssertMainThread();
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
NSString *log = RCTProfileEnd(self);
NSData *logData = [log dataUsingEncoding:NSUTF8StringEncoding];
RCTProfileSendResult(self, @"systrace", logData);
callback(logData);
}];
}

View File

@ -26,7 +26,7 @@
@interface RCTBridge (Profiling)
- (void)startProfiling;
- (void)stopProfiling;
- (void)stopProfiling:(void (^)(NSData *))callback;
@end
@ -520,7 +520,9 @@ RCT_EXPORT_METHOD(reload)
if (enabled) {
[_bridge startProfiling];
} else {
[_bridge stopProfiling];
[_bridge stopProfiling:^(NSData *logData) {
RCTProfileSendResult(_bridge, @"systrace", logData);
}];
}
}
}