GoodforGod / java-logger-benchmark

🧪 Different Java Loggers Benchmarks.
http://goodforgod.dev/java-logger-benchmark/
Apache License 2.0
16 stars 4 forks source link

'Equalize' the patterns #4

Closed elecharny closed 2 years ago

elecharny commented 2 years ago

Is your feature request related to a problem? Please describe. Pattern are not identical, the results may differ because of that

Here are the different used patterns:

Describe the solution you'd like Use the same pattern for every logger

GoodforGod commented 2 years ago

All those patterns you mentions means different things. If we are talking about date & time pattern so they are the same, but wary depending on the implementation for different loggers, the only difference here is goodforgod logger, cause it uses new java date API:

But date & time patterns are same despite different java APIs.

SLF4J-simple and goodforgod loggers use patterns ONLY for date & time, when others for whole layout.

Layout is actually the same across ALL loggers, it just have different configurations depending on implementation of course, but they are the same, you can check it yourself by running benches. Layout for all loggers looks like:

%d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%level] %logger - %msg%n%throwable

So what actually you mean by "different" patterns, when they all have same layout and same formatters for date & time, can you elaborate cause I don't see the issue

elecharny commented 2 years ago

Hi, what I mean is that if you have a pattern that uses [%level] for instance, that means there is some processing behind it. You are not exactly measuring the same thing if all the loggers aren't exposing the level or the stack trace, and that may generate some difference in the result you obtain. Not that it invalidate your tests, but it's really critically important to measure the exact same thing.

Hope it helps.

GoodforGod commented 2 years ago

I understand that and as mentioned above all loggers configured to output exactly the same messages

Pseudo layout for all loggers:

{date} [{level}] {logger} - {message}{separator}{throwable with stacktrace}

Date use same formatted - yyyy-MM-dd'T'HH:mm:ss.SSS Logger - logger full class name

So I don't get why you think they aren't the same. All output levels and stacktraces as you see in layout

There are even examples in readme in the beginning with message examples for all loggers that they are the same.

I will add this pseudo layout to readme to make it more clearly

Looks like you misunderstood what "pattern" configuration is used in each logger implementation, you can read configuration for each logger to figure that out, there are links in readme for each logger

elecharny commented 2 years ago

The output is irrelevant. What I was focusing on is the time needed to process the pattern itself. Having different patterns for the same output does not mean it takes the same time to generate the same output.

If one logger generates some part of the output even if the pattern does not describe it, then it's hard coded, and it's not the same logic and cost. I can understand the rational though.

Anyway, this is not really important. Would I want to do my homework, you provided an excellent base for that. And that's all what matters :-)

GoodforGod commented 2 years ago

Okay, I see your point now, but it is impossible to make, cause some of those loggers literally doesn't support such "pattern" layout like log4j or logback.

And this is basically irrelevant at this point, cause the idea behind the benchmark is to put all loggers in the same conditions and measure how they all handle the most common scenarios developers use and compare their implementation in such scenarios. So some loggers use as you see pattern layout, some of them don't, etc

At the end it is your choice to make, do you want performance or flexibility and what is the cost. That is the whole idea basically