google / google/flogger

Benchmarks and String Creation

Open
#316 19 comments 0 reactions 0 assignees View on GitHub
P3 type=other
Dominant language
Java
Stars
1.5k
Forks
133
Avg merge
6m
Merged PRs (30d)
7

Description

Doesn't this style of logging api incur the cost of string creation, even when the logger is off ?

I haven't looked at the byte code, but I'm wondering what exactly is ment by 'essentially free'.

I remember reading in the initial log4j that the whole reason for the usage of the imperative paradigms if, i.e.;
if (log.isDebugEnabled()) {
log.debug("foo");
}

Was to avoid the cost of the creation of the string "foo". The impartive if statement would create branching bytecode, with GOTO statements. IIt would seem to me that this functional stream log API style would result in a lot of extra string creation and garbage collection. Has anyone benchmarked it ? Where are the benchmarks ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.