From 6f77d71e861014c2bf3b33af4e834181e96a0486 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Tue, 1 Jul 2014 01:43:54 +0200 Subject: [PATCH] Show profiling information on key press --- GameLib/GameLib.c | 29 ++++++++++++++++++++--------- GameLib/Input.c | 2 ++ GameLib/Input.h | 3 +++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/GameLib/GameLib.c b/GameLib/GameLib.c index 61f50b6..4c7c7c8 100644 --- a/GameLib/GameLib.c +++ b/GameLib/GameLib.c @@ -378,6 +378,26 @@ void GameLib_DrawLoop(float f){ t_draw+=Time_GetTime()-time; fdraw_count++; + + if(Input_GetKey(InputKey_DumpProfiling)==InputKey_Pressed){ + printf("Profiling:::::::::\n"); + if(fproc_count>0){ + printf("t_proc.....:%6lld\n",t_proc/fproc_count); + printf("t_col......:%6lld\n",t_col/fproc_count); + printf("t_over.....:%6lld\n",t_over/fproc_count); + printf("t_postproc.:%6lld\n",t_postproc/fproc_count); + } + if(fdraw_count>0){ + printf("t_draw.....:%6lld\n",t_draw/fdraw_count); + } + t_proc=0; + t_col=0; + t_over=0; + t_postproc=0; + t_draw=0; + fproc_count=0; + fdraw_count=0; + } } @@ -405,15 +425,6 @@ void GameLib_Loop( fproc_count=0; fdraw_count=0; Draw_Loop(GameLib_ProcLoop,GameLib_DrawLoop); - - if (gamelib_debug) { - printf("Profiling:::::::::\n"); - printf("t_proc.....:%6lld\n",t_proc/fproc_count); - printf("t_col......:%6lld\n",t_col/fproc_count); - printf("t_over.....:%6lld\n",t_over/fproc_count); - printf("t_postproc.:%6lld\n",t_postproc/fproc_count); - printf("t_draw.....:%6lld\n",t_draw/fdraw_count); - } } diff --git a/GameLib/Input.c b/GameLib/Input.c index 15c4bb6..33b2b77 100644 --- a/GameLib/Input.c +++ b/GameLib/Input.c @@ -66,6 +66,8 @@ void Input_Frame(){ Input_SetKey(InputKey_Right,keys[SDLK_RIGHT]); Input_SetKey(InputKey_Jump,keys[SDLK_SPACE]); Input_SetKey(InputKey_Continue,keys[SDLK_RETURN]|keys[SDLK_KP_ENTER]); + + Input_SetKey(InputKey_DumpProfiling,keys[SDLK_p]); } diff --git a/GameLib/Input.h b/GameLib/Input.h index dfe41fd..4d0e807 100644 --- a/GameLib/Input.h +++ b/GameLib/Input.h @@ -33,6 +33,9 @@ typedef enum { InputKey_Right, InputKey_Jump, InputKey_Continue, + + InputKey_DumpProfiling, + InputKey_Max } InputKey;