jMonkeyEngine-Contributions / Lemur

Lemur is a jMonkeyEngine-based UI toolkit.
http://jmonkeyengine-contributions.github.io/Lemur/
BSD 3-Clause "New" or "Revised" License
116 stars 32 forks source link

Performance improvements during logging #32

Closed Pesegato closed 8 years ago

pspeed42 commented 8 years ago

Well... in this case not really. These are both only called once per application run first off... so any performance benefit is minor. Since the idea is that INFO messages are usually logged then we don't get much benefit from the "not logged" optimization that the format version of the method provides. So then it's a difference between a string append and a string format. The append is always going to perform better in that case. (And the compiler will catch typos.)

pspeed42 commented 8 years ago

Thanks for the patch, though. I'm glad others are looking at the code.

Pesegato commented 8 years ago

Hum. I thought that the string format was always preferable and therefore always use the {} syntax, if nothing else to remind the "better way" of logging... oh well.

pspeed42 commented 8 years ago

The benefit of the {} syntax is that the logging system can avoid doing the string format if the log message would be suppressed. Else string + is going to be faster. The down side of the {} syntax is that if you get it wrong then you don't know about it until that log message is output someday and your application crashes.

In this case, the savings for {} would be so small as to not be measurable (because these are logged once per app run) and considering the message is almost always output then there would be no savings at all anyway.

For readability, cut+pastability, etc. I also prefer the string + string form, personally. So you will see it's rare that I use the {} form.

On Mon, May 23, 2016 at 4:17 AM, Pesegato notifications@github.com wrote:

Hum. I thought that the string format was always preferable and therefore always use the {} syntax, if nothing else to remind the "better way" of logging... oh well.

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/jMonkeyEngine-Contributions/Lemur/pull/32#issuecomment-220915455