summaryrefslogtreecommitdiff
path: root/src/graphics.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@Simon-Elementary.(none)>2011-10-16 23:16:43 (GMT)
committer Simon Robertshaw <simon@Simon-Elementary.(none)>2011-10-16 23:16:43 (GMT)
commit44a0008d4e8f80fce9697bbde09193e837bc0072 (patch)
treee96a3df113a11ee5bb3f70ad568ff2f44e050bad /src/graphics.c
parentbbe5aabf4f85c0b83da54fb8f55b4c509c323609 (diff)
downloadpowder-44a0008d4e8f80fce9697bbde09193e837bc0072.zip
powder-44a0008d4e8f80fce9697bbde09193e837bc0072.tar.gz
Debug performance/time graph
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 5d7354d..60572dc 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -2718,6 +2718,59 @@ int sdl_open(void)
int draw_debug_info(pixel* vid, int lm, int lx, int ly, int cx, int cy, int line_x, int line_y)
{
char infobuf[256];
+ if(debug_flags & DEBUG_PERFORMANCE_FRAME || debug_flags & DEBUG_PERFORMANCE_CALC)
+ {
+ int t1, t2, x = 0, i = debug_perf_istart;
+ float partiavg = 0, frameavg = 0;
+ while(i != debug_perf_iend)
+ {
+ partiavg += abs(debug_perf_partitime[i]/100000);
+ frameavg += abs(debug_perf_frametime[i]/100000);
+ if(debug_flags & DEBUG_PERFORMANCE_CALC)
+ t1 = abs(debug_perf_partitime[i]/100000);
+ else
+ t1 = 0;
+
+ if(debug_flags & DEBUG_PERFORMANCE_FRAME)
+ t2 = abs(debug_perf_frametime[i]/100000);
+ else
+ t2 = 0;
+
+ if(t1 > YRES)
+ t1 = YRES;
+ if(t1+t2 > YRES)
+ t2 = YRES-t1;
+
+ if(t1>0)
+ draw_line(vid, x, YRES, x, YRES-t1, 0, 255, 120, XRES+BARSIZE);
+ if(t2>0)
+ draw_line(vid, x, YRES-t1, x, YRES-(t1+t2), 255, 120, 0, XRES+BARSIZE);
+
+ i++;
+ x++;
+ i %= DEBUG_PERF_FRAMECOUNT;
+ }
+
+ if(debug_flags & DEBUG_PERFORMANCE_CALC)
+ t1 = abs(partiavg / x);
+ else
+ t1 = 0;
+
+ if(debug_flags & DEBUG_PERFORMANCE_FRAME)
+ t2 = abs(frameavg / x);
+ else
+ t2 = 0;
+
+ if(t1 > YRES)
+ t1 = YRES;
+ if(t1+t2 > YRES)
+ t2 = YRES-t1;
+
+ if(t1>0)
+ fillrect(vid, x, YRES-t1-1, 5, t1+2, 0, 255, 0, 255);
+ if(t2>0)
+ fillrect(vid, x, (YRES-t1)-t2-1, 5, t2+1, 255, 0, 0, 255);
+ }
if(debug_flags & DEBUG_DRAWTOOL)
{
if(lm == 1) //Line tool