changeset 1181:b5ae6d3daf87

jmh-core: minor presentation fixes for "approximate" values.
author shade
date Fri, 03 Apr 2015 15:13:42 +0300
parents d0c8350206db
children f028eef1340d
files jmh-core/src/main/java/org/openjdk/jmh/results/Result.java jmh-core/src/main/java/org/openjdk/jmh/util/ScoreFormatter.java
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java	Thu Apr 02 14:29:12 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java	Fri Apr 03 15:13:42 2015 +0300
@@ -178,7 +178,7 @@
     @Override
     public String toString() {
         if (!Double.isNaN(getScoreError()) && !ScoreFormatter.isApproximate(getScore())) {
-            return String.format("%s \u00B1(99.9%%) %sf %s",
+            return String.format("%s \u00B1(99.9%%) %s %s",
                     ScoreFormatter.format(getScore()),
                     ScoreFormatter.formatError(getScoreError()),
                     getScoreUnit());
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/ScoreFormatter.java	Thu Apr 02 14:29:12 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ScoreFormatter.java	Fri Apr 03 15:13:42 2015 +0300
@@ -36,7 +36,8 @@
 
     public static String format(double score) {
         if (isApproximate(score)) {
-            return "\u2248 10" + superscript("" + (int)Math.round(Math.log10(score)));
+            int power = (int) Math.round(Math.log10(score));
+            return "\u2248 " + ((power != 0) ? "10" + superscript("" + power) : "0");
         } else {
             return String.format("%." + PRECISION + "f", score);
         }
@@ -44,7 +45,8 @@
 
     public static String format(int width, double score) {
         if (isApproximate(score)) {
-            return String.format("%" + width + "s", "\u2248 10" + superscript("" + (int)Math.round(Math.log10(score))));
+            int power = (int) Math.round(Math.log10(score));
+            return String.format("%" + width + "s", "\u2248 " + ((power != 0) ? "10" + superscript("" + power) : "0"));
         } else {
             return String.format("%" + width + "." + PRECISION + "f", score);
         }