Skip to content

Commit

Permalink
Instrument native library load time
Browse files Browse the repository at this point in the history
Summary: I'm interested in measuring this.

Reviewed By: alexeylang

Differential Revision: D10510275

fbshipit-source-id: e833153524413bc5ec6159ff100ade92b29e6d0c
  • Loading branch information
johnislarry authored and facebook-github-bot committed Oct 24, 2018
1 parent 1746448 commit b141363
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,34 @@

import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;

import android.os.SystemClock;
import com.facebook.soloader.SoLoader;
import com.facebook.systrace.Systrace;

public class ReactBridge {
private static volatile long sLoadStartTime = 0;
private static volatile long sLoadEndTime = 0;

private static boolean sDidInit = false;
public static void staticInit() {
// No locking required here, worst case we'll call into SoLoader twice
// which will do its own locking internally
if (!sDidInit) {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni");
SoLoader.loadLibrary("reactnativejni");
sDidInit = true;
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

public synchronized static void staticInit() {
if (sDidInit) {
return;
}
sDidInit = true;

sLoadStartTime = SystemClock.uptimeMillis();
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni");
SoLoader.loadLibrary("reactnativejni");
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
sLoadEndTime = SystemClock.uptimeMillis();
}

public static long getLoadStartTime() {
return sLoadStartTime;
}

public static long getLoadEndTime() {
return sLoadEndTime;
}
}

0 comments on commit b141363

Please sign in to comment.