Allow to configure print accuracy and fetch temprory results from profiler

This commit is contained in:
Nikolay Krasko
2016-01-12 14:51:38 +03:00
committed by Nikolay Krasko
parent 61bd0e7265
commit 5431c6937f
@@ -68,10 +68,12 @@ public class Profiler {
private boolean paused = true;
private StackTraceElement[] stackTrace;
private boolean mute;
private String formatString;
private Profiler(@NotNull String name, @NotNull Logger log) {
this.name = name;
this.log = log;
setPrintAccuracy(3);
}
public Profiler recordStackTrace(int depth) {
@@ -164,6 +166,10 @@ public class Profiler {
return this;
}
public long getCumulative() {
return cumulative;
}
public Profiler mute() {
mute = true;
return this;
@@ -227,7 +233,12 @@ public class Profiler {
return this;
}
private static String format(long delta) {
return String.format("%.3fs", delta / 1e9);
public Profiler setPrintAccuracy(int accuracy) {
formatString = "%." + accuracy + "fs";
return this;
}
private String format(long delta) {
return String.format(formatString, delta / 1e9);
}
}