package quickfix; import org.openjdk.jmh.annotations.Benchmark; import quickfix.InvalidMessage; import quickfix.Message; public class MyBenchmark { private static final String[] DATASET = new String[] { "8=FIX.4.4\0019=247\00135=s\00134=5\00149=sender\00152=20060319-09:08:20.881\001" + "56=target\00122=8\00140=2\00144=9\00148=ABC\00155=ABC\00160=20060319-09:08:19\001548=184214\001549=2\001" + "550=0\001552=2\00154=1\001453=2\001448=8\001447=D\001452=4\001448=AAA35777\001447=D\001452=3\00138=9\00154=2\001" + "453=2\001448=8\001447=D\001452=4\001448=aaa\001447=D\001452=3\00138=9\00110=056\001" , "8=FIX.4.4\0019=247\00135=s\00134=5\00149=sender\00152=20060319-09:08:20.881\001" + "56=XXXX\00122=8\00140=2\00144=9\00148=ABC\00155=ABC\00160=20060319-09:08:19\001548=184214\001549=2\001" + "550=0\001552=2\00154=1\001453=2\001448=8\001447=D\001452=4\001448=JKSA5777\001447=D\001452=3\00138=9\00154=2\001" + "453=2\001448=8\001447=D\001452=4\001448=bbb\001447=D\001452=3\00138=9\00110=056\001", "8=FIX.4.4\0019=247\00135=s\00134=5\00149=foobar\00152=20060319-09:08:20.881\001" + "56=YYY\00122=8\00140=2\00144=9\00148=ABC\00155=ABC\00160=20060319-09:08:19\001548=184214\001549=2\001" + "550=0\001552=2\00154=1\001453=2\001448=8\001447=D\001452=4\001448=HJHJH777\001447=D\001452=3\00138=9\00154=2\001" + "453=2\001448=8\001447=D\001452=4\001448=bbb\001447=D\001452=3\00138=9\00110=056\001" }; private static Message[] MSGS = new Message[3]; static { try { MSGS[0] = new Message( DATASET[0] ); MSGS[1] = new Message( DATASET[1] ); MSGS[2] = new Message( DATASET[2] ); } catch ( InvalidMessage e ) { throw new RuntimeException(e); } } @Benchmark public String testOldToString() throws InvalidMessage { // place your benchmarked code here MSGS[0].toString(); MSGS[1].toString(); return MSGS[2].toString(); } @Benchmark public String testNewToString() throws InvalidMessage { // place your benchmarked code here MSGS[0].toString2(); MSGS[1].toString2(); return MSGS[2].toString2(); } }