Skip to content

Commit

Permalink
fix: Properly initialize logback
Browse files Browse the repository at this point in the history
  • Loading branch information
hkupty committed Nov 14, 2023
1 parent 8729886 commit f6b60fb
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.JsonEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.util.LogbackMDCAdapter;
import ch.qos.logback.core.OutputStreamAppender;
import ch.qos.logback.core.encoder.Encoder;
import net.logstash.logback.encoder.LogstashEncoder;
Expand Down Expand Up @@ -99,6 +100,7 @@ private Encoder<ILoggingEvent> getLogstashEncoder() {
@Setup
public void setup() {
context.setName("JMH");
context.setMDCAdapter(new LogbackMDCAdapter());
logger = context.getLogger("jmh.test.logback");
logger.setLevel(Level.INFO);
OutputStreamAppender<ILoggingEvent> appender = new LogbackDevNullAppender();
Expand Down Expand Up @@ -140,6 +142,7 @@ public void setup() throws IOException {

logger = cache.getLoggerAt("jmh", "test", "penna");
}

@TearDown
public void tearDown() throws IOException {
fos.close();
Expand All @@ -151,10 +154,10 @@ public void penna(PennaState state, TestBehavior tb) throws IOException {
tb.log(state.logger);
}

// @Benchmark
// public void logback(LogbackState state, TestBehavior tb) throws IOException {
// tb.log(state.logger);
// }
@Benchmark
public void logback(LogbackState state, TestBehavior tb) throws IOException {
tb.log(state.logger);
}

@Test
public void runBenchmarks() throws Exception {
Expand All @@ -171,7 +174,7 @@ public void runBenchmarks() throws Exception {
.addProfiler("gc")
.addProfiler("perfnorm")
.addProfiler("perfasm", "tooBigThreshold=2100")
.threads(4)
.threads(1)
.jvm("/usr/lib/jvm/java-21-jetbrains/bin/java")
.jvmArgs("-Xmx8192m")
.build();
Expand Down

0 comments on commit f6b60fb

Please sign in to comment.