benchmarking - java benchmark with Ellipticgroup / Brent Boyer -
i trying use java benchmark mentioned here: https://www.ibm.com/developerworks/java/library/j-benchmark2/ , can downloaded here: http://www.ellipticgroup.com/html/benchmarkingarticle.html
i tried use basic example in article above:
import bb.util.benchmark; public class shortindexesloop { public static void main(string[] args) throws exception { callable<integer> task = new callable<integer>() { public integer call() { return fibonacci(35); } }; system.out.println("fibonacci(35): " + new benchmark(task)); } protected static int fibonacci(int n) throws illegalargumentexception { if (n < 0) throw new illegalargumentexception("n = " + n + " < 0"); if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); } }
but every execution of benchmark starts exception before running benchmark
jun 13, 2015 1:45:37 pm stringutil warning: string not behave expected; see cause
java.lang.exception: substring not share same underlying char[] parent string @ bb.util.stringutil.inspectstringconstructor(stringutil.java:84) @ bb.util.stringutil.<clinit>(stringutil.java:75) @ bb.io.consoleutil.<clinit>(consoleutil.java:81) @ bb.util.benchmark.sendusermsg(benchmark.java:1002) @ bb.util.benchmark.osspecificpreparation(benchmark.java:579) @ bb.util.benchmark.perform(benchmark.java:541) @ bb.util.benchmark.<init>(benchmark.java:464) @ bb.util.benchmark.<init>(benchmark.java:439) @ shortindexesloop.main(fib.java:13)
it seems call benchmark ends using following method in stringutil
private static final boolean stringcontructortrimsgarbage = inspectstringconstructor(); private static boolean inspectstringconstructor() { try { // first prove substring shares same underlying char[] parent string: string s1 = "abc123def"; string s2 = s1.substring(3, 6); char[] value1 = (char[]) reflectutil.get(s1, "value"); char[] value2 = (char[]) reflectutil.get(s2, "value"); if (value1 != value2) throw new exception("substring not share same underlying char[] parent string"); if (value2.length != s1.length()) throw new exception("value2.length = " + value2.length + " != s1.length() = " + s1.length()); // second prove string(string) constructor trims garbage chars: string s3 = new string(s2); char[] value3 = (char[]) reflectutil.get(s3, "value"); if (value3 == value2) throw new exception("new string shares same underlying char[] string arg"); if (!(value3.length < value2.length)) throw new exception("value3.length = " + value3.length + " not < value2.length = " + value2.length); return true; } catch (exception e) { logutil.getlogger2().logp(level.warning, "stringutil", "<clinit>", "string not behave expected; see cause", e); return false; } }
i don't mind exception, since benchmark library give result. however, trying compile code jar , running jar, problem. due exception rest of code won't executed in terminal
anyone has idea how solve issue?
i know old question, mabye solution useful others well: in source of stringutil
class of benchmark framework, documented, why inspection done. based on this, if have jdk substring
creates copy of relevant part of underlying char array, can comment stringcontructortrimsgarbage
flag, , in newstring
method, return s.
Comments
Post a Comment