本文整理匯總了Java中android.os.Trace.beginSection方法的典型用法代碼示例。如果您正苦於以下問題:Java Trace.beginSection方法的具體用法?Java Trace.beginSection怎麽用?Java Trace.beginSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.Trace
的用法示例。
在下文中一共展示了Trace.beginSection方法的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();
}
}
}
示例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());
}
示例3: 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));
}
示例4: 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;
}
}
示例5: 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();
}
}
}
示例6: 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();
}
}
示例7: classifyImage
import android.os.Trace; //導入方法依賴的package包/類
public Classification[] classifyImage(Bitmap bitmap) {
Trace.beginSection("create Image Buffer");
ByteBuffer byteBuffer = ByteBuffer.allocate(bitmap.getByteCount());
bitmap.copyPixelsToBuffer(byteBuffer);
byte[] bytes = byteBuffer.array();
Trace.endSection();
Trace.beginSection("color adaption");
float[] colors;
if (modelNeedsMeanAdjust) {
colors = subtractMean(bytes);
} else {
colors = extractRGBData(bytes);
}
Trace.endSection();
Trace.beginSection("Model execution");
final long startTime = SystemClock.uptimeMillis();
mPredictor.forward("data", colors);
mActivity.setLasProcessingTimeMs(SystemClock.uptimeMillis() - startTime);
final float[] result = mPredictor.getOutput(0);
Trace.endSection();
Trace.beginSection("gather top results");
Classification[] results = getTopKresults(result, 5);
Trace.endSection();
mActivity.requestRender();
return results;
}
示例8: setVData
import android.os.Trace; //導入方法依賴的package包/類
final public void setVData(Object data, boolean isAppend) {
if (VERSION.SDK_INT >= 18) {
Trace.beginSection("ViewBase.setVData");
}
mViewCache.setComponentData(data);
if (data instanceof JSONObject) {
boolean invalidate = false;
if (((JSONObject)data).optBoolean(FLAG_INVALIDATE)) {
invalidate = true;
}
List<ViewBase> cacheView = mViewCache.getCacheView();
if (cacheView != null) {
for (int i = 0, size = cacheView.size(); i < size; i++) {
ViewBase viewBase = cacheView.get(i);
List<Item> items = mViewCache.getCacheItem(viewBase);
if (null != items) {
for(int j = 0, length = items.size(); j < length; j++) {
Item item = items.get(j);
if (invalidate) {
item.invalidate(data.hashCode());
}
item.bind(data, isAppend);
}
viewBase.onParseValueFinished();
if (!viewBase.isRoot() && viewBase.supportExposure()) {
mContext.getEventManager().emitEvent(EventManager.TYPE_Exposure,
EventData
.obtainData(mContext, viewBase));
}
}
}
}
((JSONObject)data).remove(FLAG_INVALIDATE);
}
if (VERSION.SDK_INT >= 18) {
Trace.endSection();
}
}
示例9: 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);
}
}
示例10: 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;
}
示例11: startSysTraceSection
import android.os.Trace; //導入方法依賴的package包/類
/**
* 僅用於SysTrace開啟tag,不是用於控製SysTrace的開啟,你也控製不了
* 一定要配合命令行-a 使用,否則自定義tag無效
* 需要debug包
* Trace的begin與end必須在同一線程之中執行
* @param tag
*/
public static void startSysTraceSection(String tag){
if(DEBUG){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Trace.beginSection(tag);
}
}
}
示例12: 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;
}
示例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);
}
}
示例14: 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);
}
}
示例15: enterMethod
import android.os.Trace; //導入方法依賴的package包/類
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);
}
}