home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Improvement Suggestions
Why no code guard when logging?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="erikture" data-source="post: 593426" data-attributes="member: 71034"><p>Hello!</p><p></p><p>I have looked into the MediaPortal code and found that there are a lot of logging on different levels, debug, info, error and so on.</p><p>Logging is always good, but I have one question about the way it is implemented in MediaPortal.</p><p></p><p>There are no build in code guard function in the Log class.</p><p>If you write for example Log.Debug("Some debug message");</p><p>The string "Some debug message" will be constructed every time this debug method is called. If debug is not switched on then the string is thrown away, i e the string is constructed for no reason. Strings are always expensive to constuct.</p><p></p><p>If you instead write something like this:</p><p></p><p>if(Log.isDebugEnabled){</p><p> Log.Debug("Some debug message");</p><p>}</p><p></p><p>It is even more expensive if you do something like this Log.Debug(string.Format("Some message: {0}",aString)); without code guared. Then the string.Format will execute for no reason as well.</p><p></p><p>Where isDebugEnabled is a bool property, the string will only be created when needed.</p><p>Calling a bool property does not take any time.</p><p>In the logging library log4net there is methods like this.</p><p></p><p>Just a thought that might improve performance.</p><p></p><p>/Erik</p></blockquote><p></p>
[QUOTE="erikture, post: 593426, member: 71034"] Hello! I have looked into the MediaPortal code and found that there are a lot of logging on different levels, debug, info, error and so on. Logging is always good, but I have one question about the way it is implemented in MediaPortal. There are no build in code guard function in the Log class. If you write for example Log.Debug("Some debug message"); The string "Some debug message" will be constructed every time this debug method is called. If debug is not switched on then the string is thrown away, i e the string is constructed for no reason. Strings are always expensive to constuct. If you instead write something like this: if(Log.isDebugEnabled){ Log.Debug("Some debug message"); } It is even more expensive if you do something like this Log.Debug(string.Format("Some message: {0}",aString)); without code guared. Then the string.Format will execute for no reason as well. Where isDebugEnabled is a bool property, the string will only be created when needed. Calling a bool property does not take any time. In the logging library log4net there is methods like this. Just a thought that might improve performance. /Erik [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Improvement Suggestions
Why no code guard when logging?
Contact us
RSS
Top
Bottom