How to run jmh class in main method

张博文 zbw_jerry_2006 at 126.com
Tue Feb 3 05:18:53 UTC 2015


Dear JMH team:


         Thanks a lot for great tool with jmh as the JDK default micro benchmark test framework.


         Here comes my doubt as I got in touch with it not long and didn't know much about JMH:


          When I run the sample class in my eclipse with jmh-core jar(1.5.1) brought in, it also threw such exception as follows:


Caused by: java.io.UnsupportedEncodingException: cp0
at java.io.PrintStream.toCharset(PrintStream.java:96)
at java.io.PrintStream.<init>(PrintStream.java:175)
at org.openjdk.jmh.util.UnCloseablePrintStream.<init>(UnCloseablePrintStream.java:34)
at org.openjdk.jmh.runner.Runner.createOutputFormat(Runner.java:131)
... 2 more


          I notice that it would call the Utils.guessConsoleEncoding() which return the "cp0" of the encoding which I could not know why.
          by the way, my main function like this:
public static void main(String[] args) throws Exception {


Options opt = new OptionsBuilder().include(LocalAtomicLongBenchmark.class.getSimpleName()).jvmArgs("-Dfile.encoding=UTF-8").build();


new Runner(opt).run();


}
          
         I need your help and please leave me some advice for how to make it run and not suffered from the encoding (and I don't know why runner should return the
         encoding and once it was not supported, maybe the default encoding should be invoked.)


More information about the jmh-dev mailing list