URL:
<http://gna.org/patch/?1038>
Summary: Debug logging facilities performance tweaks
Project: Battle for Wesnoth
Submitted by: ilor
Submitted on: Wednesday 04/02/2008 at 17:14
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
The current debug functions provided by log.hpp and log.cpp are somewhat
inefficient. This is not really important when logging is turned on, but
there is unnecesary overhead when it is off. It is relatively easy to reduce
the overhead significantly by cutting function calls and object constructions
when debugging is off.
This patch:
- makes log_scope check the debug level before moving into the actual
logging (calling SDL_Ticks() etc).
- moves some code from log.cpp to the header file. Now checking whether
debug is active (i.e. the dont_log function) should be inlined by the
compiler. Also made log_scope ctor inline-able. This should save us function
calls when logging is off.
- adds a const char* taking ctor to log_scope to avoid the unnecesary string
construction and destruction when passed a char*. Old std::string ctor
retained to avoid changing other code.
There are some minor downsides:
- pretty much everything has to be re-compiled since log.hpp is used very
often
- the compiled code might take slighlty more space due to the inlining.
Should be largely irrelevant as the inlining boils down to one conditional
before a function call.
- log.hpp is still unnecesarily complicated imo, but I think a rewrite would
take too much time for too little gain.
- had to expose certain bits of log.cpp that were not visible from outside.
Irrelevant unless someone writes code that purposefully breaks it, as it was
possible anyway.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wednesday 04/02/2008 at 17:14 Name: log_speed_tweaks.patch Size: 4kB
By: ilor
<http://gna.org/patch/download.php?file_id=4118>
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1038>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs