|
From: Lasse Kärkkäi. <tr...@us...> - 2010-10-24 19:33:47
|
Module: performous
Branch: master
Commit: 9714183627f0a4adb4b12342cec769b8bd27bbf7
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Oct 24 18:46:04 2010 +0200
Profiler for main loop
---
game/main.cc | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 1ce92ff..f8de5de 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -2,6 +2,7 @@
#include "fs.hh"
#include "screen.hh"
#include "joystick.hh"
+#include "profiler.hh"
#include "songs.hh"
#include "backgrounds.hh"
#include "database.hh"
@@ -160,6 +161,7 @@ void mainLoop(std::string const& songlist) {
boost::xtime time = now();
unsigned frames = 0;
while (!sm.isFinished()) {
+ Profiler prof("mainloop");
if( g_take_screenshot ) {
fs::path filename;
try {
@@ -172,13 +174,16 @@ void mainLoop(std::string const& songlist) {
g_take_screenshot = false;
}
sm.updateScreen(); // exit/enter, any exception is fatal error
+ prof("misc");
try {
// Draw
window.blank();
sm.getCurrentScreen()->draw();
sm.drawNotifications();
+ prof("draw");
// Display (and wait until next frame)
window.swap();
+ prof("swap");
if (config["graphic/fps"].b()) {
++frames;
if (now() - time > 1.0) {
@@ -191,9 +196,11 @@ void mainLoop(std::string const& songlist) {
time = now();
frames = 0;
}
+ prof("fpsctrl");
// Process events for the next frame
if (midiDrums) midiDrums->process();
checkEvents_SDL(sm);
+ prof("events");
} catch (std::runtime_error& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
sm.flashMessage(std::string("ERROR: ") + e.what());
|