Skip to content

Commit

Permalink
Doublecheck Java app start performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidokert committed Jun 29, 2024
1 parent 9c15f5d commit 43be4bb
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,15 @@ void closeCobaltService(String serviceName) {
cobaltServices.remove(serviceName);
}

private void maybeReportTime(String label) {
Activity activity = activityHolder.get();
if (activity instanceof CobaltActivity) {
long javaStartTimestamp = ((CobaltActivity) activity).getAppStartTimestamp();
long elapsed_ms = (System.nanoTime() - javaStartTimestamp) / (1000 * 1000);
Log.i(TAG, "StarboardBridge::" + label + ": elapsed time: " + elapsed_ms + " ms");
}
}

/** Returns the application start timestamp. */
@SuppressWarnings("unused")
@UsedByNative
Expand All @@ -753,6 +762,9 @@ protected long getAppStartTimestamp() {
long javaStartTimestamp = ((CobaltActivity) activity).getAppStartTimestamp();
long cppTimestamp = nativeCurrentMonotonicTime();
long javaStopTimestamp = System.nanoTime();
long elapsed_micros =
(javaStopTimestamp - javaStartTimestamp) / timeNanosecondsPerMicrosecond;
Log.i(TAG, "StarboardBridge::getAppStartTimestamp: time: " + (elapsed_micros / 1000) + " ms");
return cppTimestamp
- (javaStartTimestamp - javaStopTimestamp) / timeNanosecondsPerMicrosecond;
}
Expand All @@ -762,6 +774,7 @@ protected long getAppStartTimestamp() {
@SuppressWarnings("unused")
@UsedByNative
void reportFullyDrawn() {
maybeReportTime("reportFullyDrawn");
Activity activity = activityHolder.get();
if (activity != null) {
activity.reportFullyDrawn();
Expand All @@ -771,6 +784,7 @@ void reportFullyDrawn() {
@SuppressWarnings("unused")
@UsedByNative
public void setCrashContext(String key, String value) {
maybeReportTime("setCrashContext");
Log.i(TAG, "setCrashContext Called: " + key + ", " + value);
crashContext.put(key, value);
if (this.crashContextUpdateHandler != null) {
Expand Down

0 comments on commit 43be4bb

Please sign in to comment.