Add Profiler class for diagnosing performance problems.
Unused for now, but like with the `LoggingQuery`, it is helpful to be used for debugging purposes. For example, used this to quickly figure out that it took 7 seconds to fix the PRNG stuff in FDroidApp onCreate().
This commit is contained in:
parent
62247b867f
commit
05f6f08832
@ -623,4 +623,19 @@ public final class Utils {
|
|||||||
Resources r = ctx.getResources();
|
Resources r = ctx.getResources();
|
||||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
|
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public static class Profiler {
|
||||||
|
public final long startTime = System.currentTimeMillis();
|
||||||
|
public final String logTag;
|
||||||
|
|
||||||
|
public Profiler(String logTag) {
|
||||||
|
this.logTag = logTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(String message) {
|
||||||
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
|
Utils.debugLog(logTag, "[" + duration + "ms] " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user