From a82f81eb3c506e05ebb3f702576e31cd9d862929 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 1 Dec 2009 17:36:18 +0000 Subject: [PATCH] oh man .. need to optimize the AIs... git-svn-id: http://svn.net-core.org/repos/t-engine4@85 51575b47-30f0-44d4-a5cc-537603b46e54 --- src/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.c b/src/main.c index e9b1b08410..8379b5d04c 100644 --- a/src/main.c +++ b/src/main.c @@ -179,6 +179,9 @@ void on_event(SDL_Event *event) // redraw the screen and update game logics, if any void on_tick() { + static int Frames = 0; + static int T0 = 0; + if (current_game != LUA_NOREF) { lua_rawgeti(L, LUA_REGISTRYINDEX, current_game); @@ -188,6 +191,19 @@ void on_tick() lua_rawgeti(L, LUA_REGISTRYINDEX, current_game); docall(L, 1, 0); } + + /* Gather our frames per second */ + Frames++; + { + int t = SDL_GetTicks(); + if (t - T0 >= 1000) { + float seconds = (t - T0) / 1000.0; + float fps = Frames / seconds; + printf("%d ticks in %g seconds = %g TPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } } void on_redraw() -- GitLab