Author: alink
Date: Tue May 12 20:56:07 2009
New Revision: 35604
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35604&view=rev
Log:
New debug tool to analyze invalidation performance:
When fps and debug are activated, also show the mean number of drawn hexes by
frame
If some hexes are invalidated but not drawn (off-screen anims) also show this
number between parenthesis
Also changed "30fps" to "fps: 30" for better readability of these debug info
when around 10
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
Modified: trunk/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=35604&r1=35603&r2=35604&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Tue May 12 20:56:07 2009
@@ -121,6 +121,8 @@
#endif
map_screenshot_(false),
fps_handle_(0),
+ invalidated_hexes_(0),
+ drawn_hexes_(0),
idle_anim_(preferences::idle_anim()),
idle_anim_rate_(1.0),
map_screenshot_surf_(NULL),
@@ -883,8 +885,8 @@
static int last_sample = SDL_GetTicks();
static int frames = 0;
++frames;
-
- if(frames == 10) {
+ const int sample_freq = 10;
+ if(frames == sample_freq) {
const int this_sample = SDL_GetTicks();
const int fps = (frames*1000)/(this_sample -
last_sample);
@@ -896,7 +898,15 @@
fps_handle_ = 0;
}
std::ostringstream stream;
- stream << fps << "fps";
+ stream << "fps: " << fps;
+ if (game_config::debug) {
+ stream << "\nhex: " <<
drawn_hexes_*1.0/sample_freq;
+ if (drawn_hexes_ != invalidated_hexes_)
+ stream << " (" <<
(invalidated_hexes_-drawn_hexes_)*1.0/sample_freq << ")";
+ }
+ drawn_hexes_ = 0;
+ invalidated_hexes_ = 0;
+
fps_handle_ = font::add_floating_label(stream.str(),12,
benchmark ? font::BAD_COLOUR :
font::NORMAL_COLOUR,
10,100,0,0,-1,screen_area(),font::LEFT_ALIGN);
@@ -904,6 +914,8 @@
} else if(fps_handle_ != 0) {
font::remove_floating_label(fps_handle_);
fps_handle_ = 0;
+ drawn_hexes_ = 0;
+ invalidated_hexes_ = 0;
}
flip();
@@ -1984,11 +1996,13 @@
continue;
}
draw_hex(loc);
+ drawn_hexes_+=1;
// If the tile is at the border, we start to blend it
if(!on_map && !off_map_tile) {
draw_border(loc, xpos, ypos);
}
}
+ invalidated_hexes_ += invalidated_.size();
}
void display::draw_hex(const map_location& loc) {
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=35604&r1=35603&r2=35604&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Tue May 12 20:56:07 2009
@@ -818,6 +818,9 @@
private:
/** Handle for the label which displays frames per second. */
int fps_handle_;
+ /** Count work done for the debug info displayed under fps */
+ int invalidated_hexes_;
+ int drawn_hexes_;
bool idle_anim_;
double idle_anim_rate_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits