Java Code Examples for android.os.Debug#threadCpuTimeNanos()
The following examples show how to use
android.os.Debug#threadCpuTimeNanos() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderScriptBlur.java From EtsyBlur with Apache License 2.0 | 5 votes |
private Bitmap blur(Bitmap inBitmap, Bitmap outBitmap) { long start = Debug.threadCpuTimeNanos(); int newWidth = inBitmap.getWidth(); int newHeight = inBitmap.getHeight(); synchronized (LOCK) { if (input == null || width != newWidth || height != newHeight) { width = newWidth; height = newHeight; destroyInputOutput(); input = Allocation.createFromBitmap(rs, inBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); output = Allocation.createTyped(rs, input.getType()); } input.copyFrom(inBitmap); scriptBlur.setRadius(blurConfig.radius()); scriptBlur.setInput(input); scriptBlur.forEach(output); output.copyTo(outBitmap); } if (start > 0) { long duration = Debug.threadCpuTimeNanos() - start; blurConfig.asyncPolicy().putSampleData(true, calculateComputation(newWidth, newHeight, blurConfig.radius()),duration); if (blurConfig.debug()) { Log.d(TAG, String.format(Locale.US, "RenderScriptBlur took %d ms.", duration / 1000000L)); } } return outBitmap; }
Example 2
Source File: ProxyRelativeLayout.java From springlayout with MIT License | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final long start = Debug.threadCpuTimeNanos(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); mTotalMeasuresTime += (Debug.threadCpuTimeNanos() - start); mMeasuresCount++; }
Example 3
Source File: ProxyRelativeLayout.java From springlayout with MIT License | 5 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final long start = Debug.threadCpuTimeNanos(); super.onLayout(changed, l, t, r, b); mTotalLayoutsTime += (Debug.threadCpuTimeNanos() - start); mLayoutsCount++; }
Example 4
Source File: ProxySpringLayout.java From springlayout with MIT License | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final long start = Debug.threadCpuTimeNanos(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); mTotalMeasuresTime += (Debug.threadCpuTimeNanos() - start); mMeasuresCount++; }
Example 5
Source File: ProxySpringLayout.java From springlayout with MIT License | 5 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final long start = Debug.threadCpuTimeNanos(); super.onLayout(changed, l, t, r, b); mTotalLayoutsTime += (Debug.threadCpuTimeNanos() - start); mLayoutsCount++; }
Example 6
Source File: LocalAidlServices.java From deagle with Apache License 2.0 | 5 votes |
static void destroyService(final Service service) { unregisterComponentCallbacks(service.getApplication(), service); try { final long start = Debug.threadCpuTimeNanos(); service.onDestroy(); logExcessiveElapse(start, 5, service, ".onDestroy()"); } catch (final RuntimeException e) { Log.e(TAG, "Error destroying " + service, e); } }
Example 7
Source File: Coordinator.java From ACDD with MIT License | 4 votes |
private static void runWithTiming(TaggedRunnable taggedRunnable) { long nanoTime; long j = 0; boolean isDebug = true; if (isDebug) { nanoTime = System.nanoTime(); j = Debug.threadCpuTimeNanos(); } else { nanoTime = 0; } try { taggedRunnable.run(); if (isDebug) { System.out.println("Timing - " + Thread.currentThread().getName() + " " + taggedRunnable.tag + ": " + ((Debug.threadCpuTimeNanos() - j) / 1000000) + "ms (cpu) / " + ((System.nanoTime() - nanoTime) / 1000000) + "ms (real)"); } } catch (RuntimeException e) { System.out.println("Exception in " + taggedRunnable.tag); if (isDebug) { System.out.println("Timing - " + Thread.currentThread().getName() + " " + taggedRunnable.tag + " (failed): " + ((Debug.threadCpuTimeNanos() - j) / 1000000) + "ms (cpu) / " + ((System.nanoTime() - nanoTime) / 1000000) + "ms (real)"); } } catch (Throwable th) { th.printStackTrace(); int i = 1; if (isDebug) { System.out.println("Timing - " + Thread.currentThread().getName() + " " + taggedRunnable.tag + (i != 0 ? " (failed): " : ": ") + ((Debug.threadCpuTimeNanos() - j) / 1000000) + "ms (cpu) / " + ((System.nanoTime() - nanoTime) / 1000000) + "ms (real)"); } } }