当前位置: 首页>>代码示例>>Java>>正文


Java Debug类代码示例

本文整理汇总了Java中android.os.Debug的典型用法代码示例。如果您正苦于以下问题:Java Debug类的具体用法?Java Debug怎么用?Java Debug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Debug类属于android.os包,在下文中一共展示了Debug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateStats

import android.os.Debug; //导入依赖的package包/类
private void updateStats() {
  final Runtime runtime = Runtime.getRuntime();
  final long heapMemory = runtime.totalMemory() - runtime.freeMemory();
  final StringBuilder sb = new StringBuilder(DEFAULT_MESSAGE_SIZE);
  // When changing format of output below, make sure to sync "run_comparison.py" as well
  sb.append("Heap: ");
  appendSize(sb, heapMemory);
  sb.append(" Java ");
  appendSize(sb, Debug.getNativeHeapSize());
  sb.append(" native\n");
  appendTime(sb, "Avg wait time: ", mPerfListener.getAverageWaitTime(), "\n");
  appendNumber(sb, "Requests: ", mPerfListener.getOutstandingRequests(), " outsdng ");
  appendNumber(sb, "", mPerfListener.getCancelledRequests(), " cncld\n");
  final String message = sb.toString();
  mStatsDisplay.setText(message);
  FLog.i(TAG, message);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:MainActivity.java

示例2: avgTimeEnd

import android.os.Debug; //导入依赖的package包/类
/**
 * 统计平均时常
 *
 * @param tag
 * @param msg
 */
public static void avgTimeEnd(String tag, Object... msg) {
    if (LuaViewConfig.isDebug()) {
        Map map = mAvgTime.get(tag);
        if (map != null) {//已经开始
            long lastTime = Long.valueOf(String.valueOf(map.get(LAST_TIME)));
            long totalTime = Long.valueOf(String.valueOf(map.get(TOTAL_TIME))) + Debug.threadCpuTimeNanos() - lastTime;
            map.put(TOTAL_TIME, totalTime);//总时间
            long printInterval = Long.valueOf(String.valueOf(map.get(PRINT_INTERVAL)));
            long times = Long.valueOf(String.valueOf(map.get(TIMES))) + 1;//总次数
            if (times >= printInterval) {//可以打印
                Log.d(DEFAULT_PREFIX, tag + " end " + (double) totalTime / printInterval + " " + getMsg(msg));
                mAvgTime.put(tag, null);
            } else {
                map.put(TIMES, times);//总次数
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:25,代码来源:LogUtil.java

示例3: handleMessage

import android.os.Debug; //导入依赖的package包/类
@Override
public boolean handleMessage(Message msg) {
    // TODO uncomment below code when release
    if (Debug.isDebuggerConnected()) {
        return true;
    }
    Event event = (Event) msg.obj;
    if (event != null) {
        try {
            processEvent(event);
        } catch (Exception e) {
            e.printStackTrace();
        }
        event.recycle();
    }
    // return true, so handler won't process this msg again, since we have event recycled here
    return true;
}
 
开发者ID:zhangjianli,项目名称:StallBuster,代码行数:19,代码来源:EventProcessor.java

示例4: memoryApp

import android.os.Debug; //导入依赖的package包/类
/**
 * 打印内存信息
 */
public static void memoryApp(String info) {

    if ( !DEBUG_MEMORY) {
        return;
    }

    Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
    int dalvikPrivateDirty = memoryInfo.dalvikPrivateDirty;
    int dalvikPss = memoryInfo.dalvikPss;
    int dalvikSharedDirty = memoryInfo.dalvikSharedDirty;
    int nativePrivateDirty = memoryInfo.nativePrivateDirty;
    int nativePss = memoryInfo.nativePss;
    int nativeSharedDirty = memoryInfo.nativeSharedDirty;
    int otherPss = memoryInfo.otherPss;
    int otherSharedDirty = memoryInfo.otherSharedDirty;
    String content =
        info + "-->dalvikPrivateDirty:" + dalvikPrivateDirty + ",dalvikPss:" + dalvikPss + ",dalvikSharedDirty:" + dalvikSharedDirty + ",nativePrivateDirty:" +
                nativePrivateDirty + ",nativePss:" + nativePss + ",nativeSharedDirty:" + nativeSharedDirty + ",otherPss:" + otherPss + ",otherSharedDirty:" + otherSharedDirty +
                "\n";
    Log.d(
        content);
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:26,代码来源:MemoryLog.java

示例5: MemoryResource

import android.os.Debug; //导入依赖的package包/类
public MemoryResource() {
    memoryInfoList.clear();

    memoryInfoList.add(Runtime.getRuntime().maxMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
    memoryInfoList.add(Runtime.getRuntime().freeMemory());

    this.natHeapSize = Debug.getNativeHeapSize();
    this.natHeapFreeSize = Debug.getNativeHeapFreeSize();
    this.pss = Debug.getPss();
    this.loadedClassCount = Debug.getLoadedClassCount();

    this.memoryInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memoryInfo);
}
 
开发者ID:TeamThresh,项目名称:Lantern-sdk,代码行数:17,代码来源:MemoryResource.java

示例6: getPssForService

import android.os.Debug; //导入依赖的package包/类
/**
 * Get the PSS used by the process hosting a service.
 *
 * @param packageName Package name of the service to search for.
 * @return the PSS in kB of the process hosting a service, or INVALID_PSS.
 */
@VisibleForTesting
static int getPssForService(ComponentName componentName) {
    if (componentName == null) return INVALID_PSS;
    Context context = ContextUtils.getApplicationContext();
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> services =
            activityManager.getRunningServices(1000);
    if (services == null) return INVALID_PSS;
    int pid = -1;
    for (ActivityManager.RunningServiceInfo info : services) {
        if (componentName.equals(info.service)) {
            pid = info.pid;
            break;
        }
    }
    if (pid == -1) return INVALID_PSS;
    Debug.MemoryInfo infos[] = activityManager.getProcessMemoryInfo(new int[] {pid});
    if (infos == null || infos.length == 0) return INVALID_PSS;
    return infos[0].getTotalPss();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:GSAServiceClient.java

示例7: printMemoryStatus

import android.os.Debug; //导入依赖的package包/类
/**
 * 打印当前内存占用日志,方便外界诊断。注意,这会显著消耗性能(约50ms左右)
 *
 * @param tag Used to identify the source of a log message.  It usually identifies
 *            the class or activity where the log call occurs.
 * @param msg The message you would like logged.
 */
public static int printMemoryStatus(String tag, String msg) {
    if (RePluginInternal.FOR_DEV) {
        Debug.MemoryInfo mi = new Debug.MemoryInfo();
        Debug.getMemoryInfo(mi);

        String mit = "desc=, memory_v_0_0_1, process=, " + IPC.getCurrentProcessName() +
                ", totalPss=, " + mi.getTotalPss() +
                ", dalvikPss=, " + mi.dalvikPss +
                ", nativeSize=, " + mi.nativePss +
                ", otherPss=, " + mi.otherPss + ", ";

        return Log.i(tag + "-MEMORY", mit + msg);
    }
    return -1;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:23,代码来源:LogDebug.java

示例8: dumpHeap

import android.os.Debug; //导入依赖的package包/类
public File dumpHeap() {
    if (!LeakCanaryInternals.isExternalStorageWritable()) {
        Log.d(TAG, "Could not dump heap, external storage not mounted.");
    }
    File heapDumpFile = getHeapDumpFile();
    if (heapDumpFile.exists()) {
        Log.d(TAG, "Could not dump heap, previous analysis still is in progress.");
        return NO_DUMP;
    }
    FutureResult<Toast> waitingForToast = new FutureResult();
    showToast(waitingForToast);
    if (waitingForToast.wait(5, TimeUnit.SECONDS)) {
        Toast toast = (Toast) waitingForToast.get();
        try {
            Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
            cancelToast(toast);
            return heapDumpFile;
        } catch (IOException e) {
            cleanup();
            Log.e(TAG, "Could not perform heap dump", e);
            return NO_DUMP;
        }
    }
    Log.d(TAG, "Did not dump heap, too much time waiting for Toast.");
    return NO_DUMP;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:AndroidHeapDumper.java

示例9: start

import android.os.Debug; //导入依赖的package包/类
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity,
            0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:19,代码来源:PLA_AbsListView.java

示例10: getUsedMemory

import android.os.Debug; //导入依赖的package包/类
/** 获取指定包名应用占用的内存,单位为byte */
public static long getUsedMemory(String packageName) {
	Context context = UIUtils.getContext();
	if (context == null) {
		return -1;
	}
	if (StringUtils.isEmpty(packageName)) {
		packageName = context.getPackageName();
	}
	long size = 0;
	ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
	List<ActivityManager.RunningAppProcessInfo> runapps = activityManager.getRunningAppProcesses();
	for (ActivityManager.RunningAppProcessInfo runapp : runapps) { // 遍历运行中的程序
		if (packageName.equals(runapp.processName)) {// 得到程序进程名,进程名一般就是包名,但有些程序的进程名并不对应一个包名
			// 返回指定PID程序的内存信息,可以传递多个PID,返回的也是数组型的信息
			Debug.MemoryInfo[] processMemoryInfo = activityManager.getProcessMemoryInfo(new int[]{runapp.pid});
			// 得到内存信息中已使用的内存,单位是K
			size = processMemoryInfo[0].getTotalPrivateDirty() * 1024;
		}
	}
	return size;
}
 
开发者ID:cuilitang,项目名称:CuiMarket,代码行数:23,代码来源:SystemUtils.java

示例11: println

import android.os.Debug; //导入依赖的package包/类
@Override
public void println(String x) {
    if (mStopWhenDebugging && Debug.isDebuggerConnected()) {
        return;
    }
    if (!mPrintingStarted) {
        mStartTimestamp = System.currentTimeMillis();
        mStartThreadTimestamp = SystemClock.currentThreadTimeMillis();
        mPrintingStarted = true;
        startDump();
    } else {
        final long endTime = System.currentTimeMillis();
        mPrintingStarted = false;
        if (isBlock(endTime)) {
            notifyBlockEvent(endTime);
        }
        stopDump();
    }
}
 
开发者ID:markzhai,项目名称:AndroidPerformanceMonitor,代码行数:20,代码来源:LooperMonitor.java

示例12: dumpHeap

import android.os.Debug; //导入依赖的package包/类
public static void dumpHeap(String filename) {
	try {
		Debug.dumpHprofData(filename);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:Miracle963,项目名称:zjdroid,代码行数:9,代码来源:HeapDump.java

示例13: start

import android.os.Debug; //导入依赖的package包/类
void start(int initialVelocity) {
    initialVelocity = modifyFlingInitialVelocity(initialVelocity);

    int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
    mLastFlingY = initialY;
    mScroller.fling(0, initialY, 0, initialVelocity, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);

    if (DEBUG)
        Log.d(TAG, String.format("String Fling: [%d, %d] to [%d]", initialY, initialVelocity, mScroller.getFinalY()));

    mTouchMode = TOUCH_MODE_FLING;
    post(this);

    if (PROFILE_FLINGING) {
        if (!mFlingProfilingStarted) {
            Debug.startMethodTracing("AbsListViewFling");
            mFlingProfilingStarted = true;
        }
    }
}
 
开发者ID:ysYvonne,项目名称:KitchenSecret_Android,代码行数:21,代码来源:PLA_AbsListView.java

示例14: onPause

import android.os.Debug; //导入依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    DebugLog.d("AndouKun", "onPause");

    hidePauseMessage();
    
    mGame.onPause();
    mGLSurfaceView.onPause();
    mGame.getRenderer().onPause();	// hack!
    
    if (mMethodTracing) {
        Debug.stopMethodTracing();
        mMethodTracing = false;
    }
    if (mSensorManager != null) {
        mSensorManager.unregisterListener(this);
    }
}
 
开发者ID:gogas,项目名称:replicaisland,代码行数:20,代码来源:AndouKun.java

示例15: antiDebug

import android.os.Debug; //导入依赖的package包/类
public void antiDebug() {
        try {
//            Debug.isDebuggerConnected();
            Method isDebuggerConnected = Debug.class.getMethod("isDebuggerConnected");
            XposedBridge.hookMethod(isDebuggerConnected, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
//                    Log.d("cc", "set isDebuggerConnected false");
                    param.setResult(false);
                }
            });
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:CvvT,项目名称:AppTroy,代码行数:17,代码来源:RedClock.java


注:本文中的android.os.Debug类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。