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:
Peter Serwylo 2017-03-29 15:41:06 +11:00
parent 62247b867f
commit 05f6f08832

View File

@ -623,4 +623,19 @@ public final class Utils {
Resources r = ctx.getResources();
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);
}
}
}