當前位置: 首頁>>代碼示例>>Java>>正文


Java Trace.endSection方法代碼示例

本文整理匯總了Java中android.os.Trace.endSection方法的典型用法代碼示例。如果您正苦於以下問題:Java Trace.endSection方法的具體用法?Java Trace.endSection怎麽用?Java Trace.endSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Trace的用法示例。


在下文中一共展示了Trace.endSection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDbIfNotExists

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Overridden in tests
 */
protected synchronized void createDbIfNotExists() {
    if (mOpenHelper == null) {
        if (LauncherAppState.PROFILE_STARTUP) {
            Trace.beginSection("Opening workspace DB");
        }
        mOpenHelper = new DatabaseHelper(getContext(), mListenerHandler);

        if (RestoreDbTask.isPending(getContext())) {
            if (!RestoreDbTask.performRestore(mOpenHelper)) {
                mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
            }
            // Set is pending to false irrespective of the result, so that it doesn't get
            // executed again.
            RestoreDbTask.setPending(getContext(), false);
        }

        if (LauncherAppState.PROFILE_STARTUP) {
            Trace.endSection();
        }
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:25,代碼來源:LauncherProvider.java

示例2: loadGraph

import android.os.Trace; //導入方法依賴的package包/類
private void loadGraph(InputStream is, Graph g) throws IOException {
  final long startMs = System.currentTimeMillis();

  Trace.beginSection("initializeTensorFlow");

  Trace.beginSection("readGraphDef");
  // TODO(ashankar): Can we somehow mmap the contents instead of copying them?
  byte[] graphDef = new byte[is.available()];
  final int numBytesRead = is.read(graphDef);
  if (numBytesRead != graphDef.length) {
    throw new IOException(
        "read error: read only "
            + numBytesRead
            + " of the graph, expected to read "
            + graphDef.length);
  }
  Trace.endSection();

  Trace.beginSection("importGraphDef");
  try {
    g.importGraphDef(graphDef);
  } catch (IllegalArgumentException e) {
    throw new IOException("Not a valid TensorFlow Graph serialization: " + e.getMessage());
  }
  Trace.endSection();

  Trace.endSection(); // initializeTensorFlow.

  final long endMs = System.currentTimeMillis();
  Log.i(
      TAG,
      "Model load took " + (endMs - startMs) + "ms, TensorFlow version: " + TensorFlow.version());
}
 
開發者ID:apacha,項目名稱:TensorflowAndroidDemo,代碼行數:34,代碼來源:TensorFlowInferenceInterface.java

示例3: startBinding

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Refreshes the shortcuts shown on the workspace.
 *
 * Implementation of the method from LauncherModel.Callbacks.
 */
public void startBinding() {
    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.beginSection("Starting page bind");
    }
    setWorkspaceLoading(true);

    // Clear the workspace because it's going to be rebound
    mWorkspace.clearDropTargets();
    mWorkspace.removeAllWorkspaceScreens();

    mWidgetsToAdvance.clear();
    if (mHotseat != null) {
        mHotseat.resetLayout();
    }
    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.endSection();
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:24,代碼來源:Launcher.java

示例4: calculatePrimaryAndSecondaryColor

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Return primary and secondary colors from the Material color palette that are similar to
 * {@param color}.
 */
public MaterialPalette calculatePrimaryAndSecondaryColor(int color) {
    Trace.beginSection("calculatePrimaryAndSecondaryColor");
    final float colorHue = hue(color);
    float minimumDistance = Float.MAX_VALUE;
    int indexBestMatch = 0;
    for (int i = 0; i < sPrimaryColors.length(); i++) {
        final int primaryColor = sPrimaryColors.getColor(i, 0);
        final float comparedHue = hue(primaryColor);
        // No need to be perceptually accurate when calculating color distances since
        // we are only mapping to 15 colors. Being slightly inaccurate isn't going to change
        // the mapping very often.
        final float distance = Math.abs(comparedHue - colorHue);
        if (distance < minimumDistance) {
            minimumDistance = distance;
            indexBestMatch = i;
        }
    }
    Trace.endSection();
    return new MaterialPalette(sPrimaryColors.getColor(indexBestMatch, 0), sSecondaryColors.getColor(indexBestMatch, 0));
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:25,代碼來源:MaterialColorMapUtils.java

示例5: b

import android.os.Trace; //導入方法依賴的package包/類
public final void b(VH paramVH, int paramInt)
{
  paramVH.b = paramInt;
  if (this.b) {
    paramVH.d = b(paramInt);
  }
  paramVH.a(1, 519);
  if (Build.VERSION.SDK_INT >= 18) {
    Trace.beginSection("RV OnBindView");
  }
  if ((0x400 & paramVH.i) == 0) {
    if ((paramVH.k != null) && (paramVH.k.size() != 0)) {}
  }
  for (;;)
  {
    a(paramVH, paramInt);
    paramVH.f();
    if (Build.VERSION.SDK_INT >= 18) {
      Trace.endSection();
    }
    return;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:24,代碼來源:aga.java

示例6: after

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Extract logcat buffer to a file ater test run.
 */
public void after() {
    try {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Trace.beginSection("Taking logcat");
        }
        ProcessBuilder processBuilder = new ProcessBuilder();

        processBuilder.command("logcat", "-d",
                "-f", PerfTestingUtils.getTestFile(mTestClass, mTestName, "logcat.log")
                        .getAbsolutePath());
        processBuilder.redirectErrorStream();
        Process process = processBuilder.start();
        process.waitFor();
        if (process.exitValue() != 0) {
            Log.e(LOG_TAG, "Error exit value while extracting logcat, exitValue=" +
                    process.exitValue());
        }
    } catch (Exception ignored) {
        Log.e(LOG_TAG, "Error while extracting logcat", ignored);
    } finally {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Trace.endSection();
        }
    }
}
 
開發者ID:googlecodelabs,項目名稱:android-perf-testing,代碼行數:29,代碼來源:EnableLogcatDump.java

示例7: finishBindingItems

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Callback saying that there aren't any more items to bind.
 *
 * Implementation of the method from LauncherModel.Callbacks.
 */
public void finishBindingItems() {
    Runnable r = new Runnable() {
        public void run() {
            finishBindingItems();
        }
    };
    if (waitUntilResume(r)) {
        return;
    }
    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.beginSection("Page bind completed");
    }
    if (mSavedState != null) {
        if (!mWorkspace.hasFocus()) {
            mWorkspace.getChildAt(mWorkspace.getCurrentPage()).requestFocus();
        }

        mSavedState = null;
    }

    mWorkspace.restoreInstanceStateForRemainingPages();

    setWorkspaceLoading(false);

    if (mPendingActivityResult != null) {
        handleActivityResult(mPendingActivityResult.requestCode,
                mPendingActivityResult.resultCode, mPendingActivityResult.data);
        mPendingActivityResult = null;
    }

    InstallShortcutReceiver.disableAndFlushInstallQueue(this);

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.finishBindingItems(false);
    }
    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.endSection();
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:45,代碼來源:Launcher.java

示例8: drawBouncingCircle

import android.os.Trace; //導入方法依賴的package包/類
/**
 * Clears the surface, then draws a filled circle with a shadow.
 * <p>
 * Similar to drawCircleSurface(), but the position changes based on the value of "i".
 */
private void drawBouncingCircle(Surface surface, int i) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.FILL);

    Canvas canvas = surface.lockCanvas(null);
    try {
        Trace.beginSection("drawBouncingCircle");
        Trace.beginSection("drawColor");
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        Trace.endSection(); // drawColor

        int width = canvas.getWidth();
        int height = canvas.getHeight();
        int radius, x, y;
        if (width < height) {
            // portrait
            radius = width / 4;
            x = width / 4 + ((width / 2 * i) / BOUNCE_STEPS);
            y = height * 3 / 4;
        } else {
            // landscape
            radius = height / 4;
            x = width * 3 / 4;
            y = height / 4 + ((height / 2 * i) / BOUNCE_STEPS);
        }

        paint.setShadowLayer(radius / 4 + 1, 0, 0, Color.RED);

        canvas.drawCircle(x, y, radius, paint);
        Trace.endSection(); // drawBouncingCircle
    } finally {
        surface.unlockCanvasAndPost(canvas);
    }
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:41,代碼來源:MultiSurfaceActivity.java

示例9: recognizeImage

import android.os.Trace; //導入方法依賴的package包/類
@Override
public List<Recognition> recognizeImage(final Bitmap bitmap) {
  // Log this method so that it can be analyzed with systrace.
  Trace.beginSection("Recognize");
  final ArrayList<Recognition> recognitions = new ArrayList<Recognition>();
  for (final String result : classifyImageBmp(bitmap).split("\n")) {
    Log.i(TAG, "Parsing [" + result + "]");

    // Clean up the string as needed
    final StringTokenizer st = new StringTokenizer(result);
    if (!st.hasMoreTokens()) {
      continue;
    }

    final String id = st.nextToken();
    final String confidenceString = st.nextToken();
    final float confidence = Float.parseFloat(confidenceString);

    final String title =
        result.substring(id.length() + confidenceString.length() + 2, result.length());

    if (!title.isEmpty()) {
      recognitions.add(new Recognition(id, title, confidence, null));
    }
  }
  Trace.endSection();
  return recognitions;
}
 
開發者ID:alseambusher,項目名稱:Paideia,代碼行數:29,代碼來源:TensorflowClassifier.java

示例10: stopSysTraceSection

import android.os.Trace; //導入方法依賴的package包/類
public static void stopSysTraceSection(){
    if(DEBUG){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Trace.endSection();
        }
    }

}
 
開發者ID:hss01248,項目名稱:DialogUtil,代碼行數:9,代碼來源:TestTool.java

示例11: onLayout

import android.os.Trace; //導入方法依賴的package包/類
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
  a();
  if (Build.VERSION.SDK_INT >= 18) {
    Trace.beginSection("RV OnLayout");
  }
  i();
  if (Build.VERSION.SDK_INT >= 18) {
    Trace.endSection();
  }
  a(false);
  this.l = true;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:14,代碼來源:RecyclerView.java

示例12: handleMessage

import android.os.Trace; //導入方法依賴的package包/類
@Override
public void handleMessage(Message inputMessage) {
    int    what = inputMessage.what;
    Object obj  = inputMessage.obj;

    FFmpegMuxer muxer = mWeakMuxer.get();
    if (muxer == null) {
        Log.w(TAG, "FFmpegHandler.handleMessage: muxer is null");
        return;
    }

    switch (what) {
        case MSG_ADD_TRACK:
            if (TRACE) Trace.beginSection("addTrack");
            muxer.handleAddTrack((MediaFormat) obj);
            if (TRACE) Trace.endSection();
            break;
        case MSG_WRITE_FRAME:
            if (TRACE) Trace.beginSection("writeSampleData");
            WritePacketData data = (WritePacketData) obj;
            muxer.handleWriteSampleData(data.mEncoder,
                    data.mTrackIndex,
                    data.mBufferIndex,
                    data.mData,
                    data.getBufferInfo());
            if (TRACE) Trace.endSection();
            break;
        case MSG_FORCE_SHUTDOWN:
            muxer.handleForceStop();
            break;

        default:
            throw new RuntimeException("Unexpected msg what=" + what);
    }
}
 
開發者ID:PerchLive,項目名稱:PerchBroadcast-Android-SDK,代碼行數:36,代碼來源:FFmpegMuxer.java

示例13: handleMessage

import android.os.Trace; //導入方法依賴的package包/類
@Override
public void handleMessage(Message inputMessage) {
    int what = inputMessage.what;
    Object obj = inputMessage.obj;

    FFmpegMuxer muxer = mWeakMuxer.get();
    if (muxer == null) {
        Log.w(TAG, "FFmpegHandler.handleMessage: muxer is null");
        return;
    }

    switch (what) {
        case MSG_ADD_TRACK:
            if (TRACE) Trace.beginSection("addTrack");
            muxer.handleAddTrack((MediaFormat) obj);
            if (TRACE) Trace.endSection();
            break;
        case MSG_WRITE_FRAME:
            if (TRACE) Trace.beginSection("writeSampleData");
            WritePacketData data = (WritePacketData) obj;
            muxer.handleWriteSampleData(data.mEncoder,
                    data.mTrackIndex,
                    data.mBufferIndex,
                    data.mData,
                    data.getBufferInfo());
            if (TRACE) Trace.endSection();
            break;
        case MSG_FORCE_SHUTDOWN:
            muxer.handleForceStop();
            break;

        default:
            throw new RuntimeException("Unexpected msg what=" + what);
    }
}
 
開發者ID:Kickflip,項目名稱:kickflip-android-sdk,代碼行數:36,代碼來源:FFmpegMuxer.java

示例14: exitMethod

import android.os.Trace; //導入方法依賴的package包/類
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());
}
 
開發者ID:JakeWharton,項目名稱:hugo,代碼行數:28,代碼來源:Hugo.java

示例15: recognizeImage

import android.os.Trace; //導入方法依賴的package包/類
@Override
public List<Recognition> recognizeImage(final Bitmap bitmap) {
    // Log this method so that it can be analyzed with systrace.
    Trace.beginSection("recognizeImage");

    Trace.beginSection("preprocessBitmap");
    // Preprocess the image data from 0-255 int to normalized float based
    // on the provided parameters.
    bitmap.getPixels(intValues, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
    for (int i = 0; i < intValues.length; ++i) {
        final int val = intValues[i];
        floatValues[i * 3 + 0] = (((val >> 16) & 0xFF) - imageMean) / imageStd;
        floatValues[i * 3 + 1] = (((val >> 8) & 0xFF) - imageMean) / imageStd;
        floatValues[i * 3 + 2] = ((val & 0xFF) - imageMean) / imageStd;
    }
    Trace.endSection();

    // Copy the input data into TensorFlow.
    Trace.beginSection("fillNodeFloat");
    inferenceInterface.fillNodeFloat(
            inputName, new int[]{1, inputSize, inputSize, 3}, floatValues);
    Trace.endSection();

    // Run the inference call.
    Trace.beginSection("runInference");
    inferenceInterface.runInference(outputNames);
    Trace.endSection();

    // Copy the output Tensor back into the output array.
    Trace.beginSection("readNodeFloat");
    inferenceInterface.readNodeFloat(outputName, outputs);
    Trace.endSection();

    // Find the best classifications.
    PriorityQueue<Recognition> pq =
            new PriorityQueue<Recognition>(
                    3,
                    new Comparator<Recognition>() {
                        @Override
                        public int compare(Recognition lhs, Recognition rhs) {
                            // Intentionally reversed to put high confidence at the head of the queue.
                            return Float.compare(rhs.getConfidence(), lhs.getConfidence());
                        }
                    });
    for (int i = 0; i < outputs.length; ++i) {
        if (outputs[i] > THRESHOLD) {
            pq.add(
                    new Recognition(
                            "" + i, labels.size() > i ? labels.get(i) : "unknown", outputs[i], null));
        }
    }
    final ArrayList<Recognition> recognitions = new ArrayList<Recognition>();
    int recognitionsSize = Math.min(pq.size(), MAX_RESULTS);
    for (int i = 0; i < recognitionsSize; ++i) {
        recognitions.add(pq.poll());
    }
    Trace.endSection(); // "recognizeImage"
    return recognitions;
}
 
開發者ID:MindorksOpenSource,項目名稱:AndroidTensorFlowMachineLearningExample,代碼行數:60,代碼來源:TensorFlowImageClassifier.java


注:本文中的android.os.Trace.endSection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。