Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

AsyncLogger: avoid useless concatenations if debug is disabled #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

AsyncLogger: avoid useless concatenations if debug is disabled #52

wants to merge 1 commit into from

Conversation

jcodagnone
Copy link

Save same CPU cycles avoiding concatenating strings that wont be used when debug is disabled (also saves some GC cycles).

@@ -666,7 +674,9 @@ public void run() {
} catch (InterruptedException e) {
// We got interrupted, stop
dbg( "Asynchronous socket writer interrupted");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add this call under the if as well... once debug is disabled there is no point in calling it. ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbg() will check if debug is enabled, so it wont be a gain (the gain is in avoiding the string concatenation).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew it. But, even though you will reduce one if test. ;)

@m0wfo
Copy link
Contributor

m0wfo commented Aug 25, 2016

-1 Nope. Are the debug guards around accessors really a performance improvement? @jcodagnone Let's talk about setting up some JMH benchmarks for finding pain-points (and yes, you're probably correct in assuming there are some in addLineToQueue). But a PR without context is just uninformed and [I'm forced to presume] premature optimization; do you have any throughput data to inform this change?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants