I've been looking at the various scala logging libraries lately, and the vast majority of them implement their logging functions as
def debug(s: => String)
So that if you have debug logging turned off, it won't execute the statement. However, I just came across logula which specifically states as one of its benefits
Unlike a lot of Scala logging libraries, Logula doesn't use pass-by-name semantics (e.g., f: => A) for its logging statements, which means two things:
- The Scala compiler doesn't have to create one-off closure objects for each logging statement. This should reduce the amount of garbage collection pressure.
Which actually makes total sense to me. So my question is, is there any real world performance benchmarks/data comparing the 2 approaches? Ideally something from a live project versus contrived benchmarks?
Personally, I think this sort of first-principles understanding of the tradeoffs is even more valuable than a case study of a particular application
While I definitely agree with the principle here, reality can be a completely different beast than what you anticipate. That's why I'm looking for real life cases instead of benchmarks, because anyone can write a benchmark that makes one way look a million times faster. Mostly for my own curiosity, because honestly, what application is logging really the bottleneck? – Khorma