本文整理匯總了Java中android.os.Trace類的典型用法代碼示例。如果您正苦於以下問題:Java Trace類的具體用法?Java Trace怎麽用?Java Trace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Trace類屬於android.os包,在下文中一共展示了Trace類的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: install
import android.os.Trace; //導入依賴的package包/類
static void install() {
if (!installed) {
installed = true;
if (isSupported()) {
try {
Method traceBegin = Trace.class.getDeclaredMethod("traceBegin", long.class, String.class);
Method traceEnd = Trace.class.getDeclaredMethod("traceEnd", long.class);
Hook.hook(traceBegin, ViewPerformanceSampler.class.getDeclaredMethod("traceBegin", long.class, String.class));
Hook.hook(traceEnd, ViewPerformanceSampler.class.getDeclaredMethod("traceEnd", long.class));
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
}
示例4: 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();
}
}
示例5: 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));
}
示例6: 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;
}
}
示例7: 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();
}
}
}
示例8: run
import android.os.Trace; //導入依賴的package包/類
@Override
public void run() {
Trace.beginSection("UPDATE");
mTextView.setText(String.valueOf(System.currentTimeMillis() - mStartTime));
mTextView.post(mUpdateTextView);
Trace.endSection();
}
示例9: 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();
}
}
示例10: 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);
}
}
示例11: 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;
}
示例12: 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();
}
}
示例13: 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;
}
示例14: 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);
}
}
}
示例15: 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();
}
}
}