android.os.Trace类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中android.os.Trace类的一些代码示例,展示了Trace类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Trace类的具体详情如下:
包路径:android.os.Trace
类名称:Trace

Trace介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

switch(appStep) {
  case BeginFrame:
    android.os.Trace.beginSection("Frame");
    break;
  case QueuedTasks:
    android.os.Trace.beginSection("QueuedTask");
    break;
  case ProcessInput:
    android.os.Trace.endSection();
    android.os.Trace.beginSection("ProcessInput");
    break;
  case ProcessAudio:
    android.os.Trace.endSection();
    android.os.Trace.beginSection("ProcessAudio");
    break;
  case StateManagerUpdate:
    android.os.Trace.endSection();
    android.os.Trace.beginSection("StateManagerUpdate");
    break;
  case SpatialUpdate:
    android.os.Trace.endSection();
    android.os.Trace.beginSection("SpatialUpdate");
    break;
  case StateManagerRender:
    android.os.Trace.endSection();
    android.os.Trace.beginSection("StateManagerRender");
    break;
  case RenderFrame:
    android.os.Trace.endSection();

代码示例来源:origin: robolectric/robolectric

/**
 * Ends the most recent active trace section.
 *
 * @throws {@link AssertionError} if called without any active trace section.
 */
@Implementation(minSdk = JELLY_BEAN_MR2)
protected static void endSection() {
 if (Trace.isTagEnabled(TRACE_TAG_APP)) {
  synchronized (lock) {
   if (currentSections.isEmpty()) {
    Log.e(TAG, "Trying to end a trace section that was never started");
    return;
   }
   previousSections.offer(currentSections.removeFirst());
  }
 }
}

代码示例来源:origin: facebook/litho

@Override
public void beginSection(String name) {
 if (ComponentsConfiguration.IS_INTERNAL_BUILD
   && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
  Trace.beginSection(name);
 }
}

代码示例来源:origin: facebook/litho

@Override
public void endSection() {
 if (ComponentsConfiguration.IS_INTERNAL_BUILD &&
   Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
  Trace.endSection();
 }
}

代码示例来源:origin: facebook/litho

@Override
public void flush() {
 Trace.beginSection(mName);
}

代码示例来源:origin: google/ExoPlayer

@TargetApi(18)
private static void endSectionV18() {
 android.os.Trace.endSection();
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void vpStep(VpStep vpStep, ViewPort vp, RenderQueue.Bucket bucket) {
  if (androidApiLevel >= 18) {
    switch (vpStep) {
      case BeginRender:
        android.os.Trace.beginSection("Render: " + vp.getName());
        break;
      case RenderScene:
        android.os.Trace.beginSection("RenderScene: " + vp.getName());
        break;
      case PostQueue:
        android.os.Trace.endSection();
        android.os.Trace.beginSection("PostQueue: " + vp.getName());
        break;
      case FlushQueue:
        android.os.Trace.endSection();
        android.os.Trace.beginSection("FlushQueue: " + vp.getName());
        break;
      case PostFrame:
        android.os.Trace.endSection();
        android.os.Trace.beginSection("PostFrame: " + vp.getName());
        break;
      case EndRender:
        android.os.Trace.endSection();
        android.os.Trace.endSection();
        break;
    }
  }
}

代码示例来源:origin: google/ExoPlayer

@TargetApi(18)
private static void beginSectionV18(String sectionName) {
 android.os.Trace.beginSection(sectionName);
}

代码示例来源:origin: JakeWharton/hugo

private static void exitMethod(JoinPoint joinPoint, Object result, long lengthMillis) {
 if (!enabled) return;
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
  Trace.endSection();
 }
 Signature signature = joinPoint.getSignature();
 Class<?> cls = signature.getDeclaringType();
 String methodName = signature.getName();
 boolean hasReturnType = signature instanceof MethodSignature
   && ((MethodSignature) signature).getReturnType() != void.class;
 StringBuilder builder = new StringBuilder("\u21E0 ")
   .append(methodName)
   .append(" [")
   .append(lengthMillis)
   .append("ms]");
 if (hasReturnType) {
  builder.append(" = ");
  builder.append(Strings.toString(result));
 }
 Log.v(asTag(cls), builder.toString());
}

代码示例来源:origin: robolectric/robolectric

/** Starts a new trace section with given name. */
@Implementation(minSdk = JELLY_BEAN_MR2)
protected static void beginSection(String sectionName) {
 if (Trace.isTagEnabled(TRACE_TAG_APP)) {
  if (crashOnIncorrectUsage) {
   if (sectionName.length() > MAX_SECTION_NAME_LEN) {
    throw new IllegalArgumentException("sectionName is too long");
   }
  } else if (sectionName == null) {
   Log.w(TAG, "Section name cannot be null");
   return;
  } else if (sectionName.length() > MAX_SECTION_NAME_LEN) {
   Log.w(TAG, "Section name is too long");
   return;
  }
  synchronized (lock) {
   currentSections.addFirst(sectionName);
  }
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void endSection_oneSectionButCalledTwice_doesNotThrow() throws Exception {
 Trace.beginSection("section1");
 Trace.endSection();
 Trace.endSection();
 // Should not crash.
}

代码示例来源:origin: JakeWharton/hugo

private static void enterMethod(JoinPoint joinPoint) {
 if (!enabled) return;
 CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
 Class<?> cls = codeSignature.getDeclaringType();
 String methodName = codeSignature.getName();
 String[] parameterNames = codeSignature.getParameterNames();
 Object[] parameterValues = joinPoint.getArgs();
 StringBuilder builder = new StringBuilder("\u21E2 ");
 builder.append(methodName).append('(');
 for (int i = 0; i < parameterValues.length; i++) {
  if (i > 0) {
   builder.append(", ");
  }
  builder.append(parameterNames[i]).append('=');
  builder.append(Strings.toString(parameterValues[i]));
 }
 builder.append(')');
 if (Looper.myLooper() != Looper.getMainLooper()) {
  builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
 }
 Log.v(asTag(cls), builder.toString());
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
  final String section = builder.toString().substring(2);
  Trace.beginSection(section);
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void endSection_calledBeforeBeginning_doesNotThrow() throws Exception {
 Trace.endSection();
 // Should not crash.
}

代码示例来源:origin: org.robolectric/shadows-framework

/**
 * Ends the most recent active trace section.
 *
 * @throws {@link AssertionError} if called without any active trace section.
 */
@Implementation(minSdk = JELLY_BEAN_MR2)
protected static void endSection() {
 if (Trace.isTagEnabled(TRACE_TAG_APP)) {
  synchronized (lock) {
   if (currentSections.isEmpty()) {
    Log.e(TAG, "Trying to end a trace section that was never started");
    return;
   }
   previousSections.offer(currentSections.removeFirst());
  }
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void endSection_twoSequentialSections_closesAllSections() throws Exception {
 Trace.beginSection("section1");
 Trace.endSection();
 Trace.beginSection("section2");
 Trace.endSection();
 assertThat(ShadowTrace.getCurrentSections()).isEmpty();
 assertThat(ShadowTrace.getPreviousSections()).containsExactly("section1", "section2");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void beginSection_tagIsNullAndCrashDisabled_doesNotThrow() throws Exception {
 ShadowTrace.doNotUseSetCrashOnIncorrectUsage(false);
 Trace.beginSection(null);
 // Should not crash.
}

代码示例来源:origin: halfhp/androidplot

public static void end() {
    if(Build.VERSION.SDK_INT >= 18) {
      Trace.endSection();
    } else {
      // TODO: alternate impl?
    }
  }
}

代码示例来源:origin: org.robolectric/shadows-framework

/** Starts a new trace section with given name. */
@Implementation(minSdk = JELLY_BEAN_MR2)
protected static void beginSection(String sectionName) {
 if (Trace.isTagEnabled(TRACE_TAG_APP)) {
  if (crashOnIncorrectUsage) {
   if (sectionName.length() > MAX_SECTION_NAME_LEN) {
    throw new IllegalArgumentException("sectionName is too long");
   }
  } else if (sectionName == null) {
   Log.w(TAG, "Section name cannot be null");
   return;
  } else if (sectionName.length() > MAX_SECTION_NAME_LEN) {
   Log.w(TAG, "Section name is too long");
   return;
  }
  synchronized (lock) {
   currentSections.addFirst(sectionName);
  }
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void endSection_twoRecursiveSectionsAndCalledTwice_closesAllSections() throws Exception {
 Trace.beginSection("section1");
 Trace.beginSection("section2");
 Trace.endSection();
 Trace.endSection();
 assertThat(ShadowTrace.getCurrentSections()).isEmpty();
 assertThat(ShadowTrace.getPreviousSections()).containsExactly("section2", "section1");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void beginSection_calledTwice_addsBothSections() throws Exception {
 Trace.beginSection("section1");
 Trace.beginSection("section2");
 assertThat(ShadowTrace.getCurrentSections()).containsExactly("section1", "section2");
 assertThat(ShadowTrace.getPreviousSections()).isEmpty();
}

相关文章

微信公众号

最新文章

更多