From 5431c6937f110632631aa32da2df13e7f364af88 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 12 Jan 2016 14:51:38 +0300 Subject: [PATCH] Allow to configure print accuracy and fetch temprory results from profiler --- .../src/org/jetbrains/kotlin/utils/Profiler.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/Profiler.java b/compiler/util/src/org/jetbrains/kotlin/utils/Profiler.java index 92c8107855f..2da13cf95a9 100644 --- a/compiler/util/src/org/jetbrains/kotlin/utils/Profiler.java +++ b/compiler/util/src/org/jetbrains/kotlin/utils/Profiler.java @@ -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); } }