| Nothing | No impact (obviously) |
| Calling an empty private final function with a static string in parameter | No impact |
| Calling an empty private final function with a dynamically composed string (eg "iteration" + i) | Large impact |
| Calling an empty private final function with a static string and integer (in separate params) | No impact |
| Calling logger.debug on an slf4j logger with attached but disabled logback logger with static string | 8,0 × 10-9 seconds per invocation |
| Calling logger.debug on an slf4j logger with attached but disabled logback logger with static string and int | 2,14 × 10-8 seconds per invocation |
| Calling logger.debug on an slf4j logger with attached but disabled logback logger with static string and String | 1,8 × 10-8 seconds per invocation |
The last items mean calling it like this: logger.debug("something {}", i); . In this table large impact means "I let it run for 40 minutes after which I gave up and spent the next 15 minutes trying to avoid my computer crashing because of thermal overload (lots of "don't you die on me" and mouth-to-fan resuscitation was involved).
The overhead caused by using slf4j statically with a static string isn't too bad, but when using the {} syntax, logging with an object in parameter seems to take about twice as long as logging only a simple string. Logging an integer seems to take even longer than that due to auto-boxing.
I also tried adding a if(logger.isDebugEnabled()) statement before the logger.debug() statement but this did not have any impact. So there's no need to do stuff like
if(logger.isDebugEnabled())
logger.debug("entering whatever");
as long as you're not doing anything funny in the logging statement. The difference is smaller than what I thought it to be earlier, but I'd still like to give the LadderQ the best possible chances. So I guess that I'll use a small interface and decide on compile time to either send debugging info to slf4j, or do nothing with it at all. This has no overhead and still allows me to keep the debug statements.
<Insert an obligatory clenbuterol zero zero zero zero joke about the "0,0000001038 seconds per invocation">
Dag Ives,
BeantwoordenVerwijderenWat betreft het laatste punt is dit ook zo bij het meegeven van Objects voor {} (i.e. mogelijk is dit auto-boxing overhead)?
Desalniettemin interessant om weten... .
mvg,
Kurt
De post is geupdate voor de nieuwe data.
BeantwoordenVerwijderenMvg
Ives