@@ -0,0 +1,2063 @@
+/*%0A * Copyright 2017 Matt Sicker%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.musigma.logging.jmh;%0A%0Aimport org.musigma.logging.Layout;%0Aimport org.musigma.logging.LogEvent;%0Aimport org.musigma.logging.SimpleLayout;%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.Scope;%0Aimport org.openjdk.jmh.annotations.State;%0Aimport org.openjdk.jmh.runner.Runner;%0Aimport org.openjdk.jmh.runner.RunnerException;%0Aimport org.openjdk.jmh.runner.options.Options;%0Aimport org.openjdk.jmh.runner.options.OptionsBuilder;%0A%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.charset.StandardCharsets;%0A%0A/**%0A *%0A */%0A@State(Scope.Benchmark)%0Apublic class LayoutBenchmark %7B%0A%0A    private Layout layout = new SimpleLayout(StandardCharsets.ISO_8859_1);%0A    private LogEvent event = new LogEvent(%22Test message%22, System.currentTimeMillis());%0A%0A    @State(Scope.Thread)%0A    public static class ReusableBuffer %7B%0A        private ByteBuffer buf = ByteBuffer.allocateDirect(8192);%0A    %7D%0A%0A    @Benchmark%0A    public ByteBuffer encode1() %7B%0A        return layout.encode(event);%0A    %7D%0A%0A    @Benchmark%0A    public void encode2(ReusableBuffer buffer) %7B%0A        layout.encode(event, buffer.buf);%0A        buffer.buf.clear();%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws RunnerException %7B%0A        Options options = new OptionsBuilder()%0A            .include(LayoutBenchmark.class.getName())%0A            .warmupIterations(10)%0A            .measurementIterations(10)%0A            .forks(1)%0A            .build();%0A%0A        new Runner(options).run();%0A    %7D%0A%7D%0A

Add benchmark for layout