Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_evas
Modified Files:
ecore_evas.c ecore_evas_fb.c ecore_evas_private.h
ecore_evas_x.c
Log Message:
debugging stuff to help profile an application using evas/ecore etc. to see
where (rougly) time is spent (as it runs - dynamically). quite useful if your
code is dropping frames to keep animation going - but u'd like to know when
exactly its happening so you can lean down the graphics design or the code in
those situations.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_evas/ecore_evas.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ecore_evas.c 16 Mar 2004 23:52:46 -0000 1.9
+++ ecore_evas.c 17 Mar 2004 05:14:13 -0000 1.10
@@ -5,34 +5,6 @@
#include "Ecore_Evas.h"
static int _ecore_evas_init_count = 0;
-static int _ecore_evas_fps_debug = 0;
-static double _ecore_evas_fps_min = 0;
-static double _ecore_evas_fps_avg_min = 0;
-static int _ecore_evas_fps_avg_count = 1;
-static Ecore_Timer *_ecore_evas_fps_timer = NULL;
-
-static int
-_ecore_evas_cb_fps_debug_timer(void *data)
-{
- static int frame_count = 0;
- static double fps_count = 0.0;
- static double pt = 0.0;
- double t, fps;
-
- t = ecore_time_get();
- frame_count++;
- if (pt == 0.0)
- {
- pt = t;
- return 1;
- }
- if (t == pt) return 1;
- fps = 1.0 / (t - pt);
- if (fps > (2 * _ecore_evas_fps_avg_min)) return 1;
- printf("ECORE_EVAS_FPS_DEBUG: FPS = %3.3f\n", fps);
- pt = t;
- return 1;
-}
/**
* Init the Evas system.
@@ -45,23 +17,6 @@
{
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
- if (getenv("ECORE_EVAS_FPS_DEBUG"))
- {
- if (getenv("ECORE_EVAS_FPS_MIN"))
- _ecore_evas_fps_min = atof(getenv("ECORE_EVAS_FPS_MIN"));
- if (getenv("ECORE_EVAS_FPS_AVERAGE_MIN"))
- _ecore_evas_fps_avg_min = atof(getenv("ECORE_EVAS_FPS_AVERAGE_MIN"));
- if (getenv("ECORE_EVAS_FPS_AVERAGE_COUNT"))
- _ecore_evas_fps_avg_count = atof(getenv("ECORE_EVAS_FPS_AVERAGE_COUNT"));
- _ecore_evas_fps_debug = 1;
- printf("%3.3f: %3.3f: %i\n",
- _ecore_evas_fps_min,
- _ecore_evas_fps_avg_min,
- _ecore_evas_fps_avg_count);
- _ecore_evas_fps_timer = ecore_timer_add(1.0 / (_ecore_evas_fps_avg_min * 2),
- _ecore_evas_cb_fps_debug_timer,
- NULL);
- }
return _ecore_evas_init_count;
}
@@ -1485,3 +1440,76 @@
} else
return ee->prop.sticky ? 1:0;
}
+
+/* fps debug calls - for debugging how much time your app actually spends */
+/* rendering graphics... :) */
+
+static _ecore_evas_fps_debug_init_count = 0;
+static int _ecore_evas_fps_debug_fd = -1;
+unsigned int *_ecore_evas_fps_rendertime_mmap = NULL;
+
+void
+_ecore_evas_fps_debug_init(void)
+{
+ char buf[4096];
+
+ _ecore_evas_fps_debug_init_count++;
+ if (_ecore_evas_fps_debug_init_count > 1) return;
+ snprintf(buf, sizeof(buf), "/tmp/.ecore_evas_fps_debug-%i", (int)getpid());
+ _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR);
+ if (_ecore_evas_fps_debug_fd < 0)
+ {
+ unlink(buf);
+ _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR);
+ }
+ if (_ecore_evas_fps_debug_fd >= 0)
+ {
+ unsigned int zero = 0;
+
+ write(_ecore_evas_fps_debug_fd, &zero, sizeof(unsigned int));
+ _ecore_evas_fps_rendertime_mmap = mmap(NULL, sizeof(unsigned int),
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ _ecore_evas_fps_debug_fd, 0);
+ }
+}
+
+void
+_ecore_evas_fps_debug_shutdown(void)
+{
+ _ecore_evas_fps_debug_init_count--;
+ if (_ecore_evas_fps_debug_init_count > 0) return;
+ if (_ecore_evas_fps_debug_fd >= 0)
+ {
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "/tmp/.ecore_evas_fps_debug-%i", (int)getpid());
+ unlink(buf);
+ if (_ecore_evas_fps_rendertime_mmap)
+ {
+ munmap(_ecore_evas_fps_rendertime_mmap, sizeof(int));
+ _ecore_evas_fps_rendertime_mmap = NULL;
+ }
+ close(_ecore_evas_fps_debug_fd);
+ _ecore_evas_fps_debug_fd = -1;
+ }
+}
+
+void
+_ecore_evas_fps_debug_rendertime_add(double t)
+{
+ if ((_ecore_evas_fps_debug_fd >= 0) &&
+ (_ecore_evas_fps_rendertime_mmap))
+ {
+ unsigned int tm;
+
+ tm = (unsigned int)(t * 1000000.0);
+ /* i know its not 100% theoretically guaranteed, but i'd say a write */
+ /* of an int could be considered atomic for all practical purposes */
+ /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */
+ /* this can run for about 4294 seconds becore looping. if you are */
+ /* doing performance testing in one run for over an hour... well */
+ /* time to restart or handle a loop condition :) */
+ *(_ecore_evas_fps_rendertime_mmap) += tm;
+ }
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ecore_evas_fb.c 20 Feb 2004 07:06:27 -0000 1.6
+++ ecore_evas_fb.c 17 Mar 2004 05:14:13 -0000 1.7
@@ -10,6 +10,8 @@
#ifdef BUILD_ECORE_EVAS_FB
static int _ecore_evas_init_count = 0;
+static int _ecore_evas_fps_debug = 0;
+
static Ecore_Evas *ecore_evases = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[5];
static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
@@ -167,7 +169,12 @@
_ecore_evas_idle_enter(void *data)
{
Ecore_List *l;
-
+ double t1, t2;
+
+ if (_ecore_evas_fps_debug)
+ {
+ t1 = ecore_time_get();
+ }
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
@@ -180,6 +187,11 @@
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
}
}
+ if (_ecore_evas_fps_debug)
+ {
+ t2 = ecore_time_get();
+ _ecore_evas_fps_debug_rendertime_add(t2 - t1);
+ }
return 1;
}
@@ -188,12 +200,14 @@
{
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
+ if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN,
_ecore_evas_event_key_down, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP,
_ecore_evas_event_key_up, NULL);
ecore_evas_event_handlers[2] =
ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN,
_ecore_evas_event_mouse_button_down, NULL);
ecore_evas_event_handlers[3] =
ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP,
_ecore_evas_event_mouse_button_up, NULL);
ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE,
_ecore_evas_event_mouse_move, NULL);
+ if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
return _ecore_evas_init_count;
}
@@ -376,6 +390,7 @@
ecore_event_handler_del(ecore_evas_event_handlers[i]);
ecore_idle_enterer_del(ecore_evas_idle_enterer);
ecore_evas_idle_enterer = NULL;
+ if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
}
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
return _ecore_evas_init_count;
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ecore_evas_private.h 16 Dec 2003 05:54:46 -0000 1.4
+++ ecore_evas_private.h 17 Mar 2004 05:14:13 -0000 1.5
@@ -1,6 +1,11 @@
#ifndef _ECORE_EVAS_PRIVATE_H
#define _ECORE_EVAS_PRIVATE_H
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
#include <Evas.h>
#define ECORE_MAGIC_EVAS 0x76543211
@@ -163,4 +168,8 @@
int _ecore_evas_fb_shutdown(void);
#endif
+void _ecore_evas_fps_debug_init(void);
+void _ecore_evas_fps_debug_shutdown(void);
+void _ecore_evas_fps_debug_rendertime_add(double t);
+
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ecore_evas_x.c 20 Feb 2004 07:06:27 -0000 1.11
+++ ecore_evas_x.c 17 Mar 2004 05:14:13 -0000 1.12
@@ -10,6 +10,8 @@
#ifdef BUILD_ECORE_X
static int _ecore_evas_init_count = 0;
+static int _ecore_evas_fps_debug = 0;
+
static Ecore_Evas *ecore_evases = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[16];
static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
@@ -432,7 +434,12 @@
_ecore_evas_idle_enter(void *data)
{
Ecore_List *l;
-
+ double t1, t2;
+
+ if (_ecore_evas_fps_debug)
+ {
+ t1 = ecore_time_get();
+ }
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
@@ -527,6 +534,11 @@
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
}
ecore_x_flush();
+ if (_ecore_evas_fps_debug)
+ {
+ t2 = ecore_time_get();
+ _ecore_evas_fps_debug_rendertime_add(t2 - t1);
+ }
return 1;
}
@@ -535,6 +547,7 @@
{
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
+ if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_X_EVENT_KEY_DOWN,
_ecore_evas_event_key_down, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_X_EVENT_KEY_UP,
_ecore_evas_event_key_up, NULL);
@@ -552,6 +565,7 @@
ecore_evas_event_handlers[13] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW,
_ecore_evas_event_window_show, NULL);
ecore_evas_event_handlers[14] = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE,
_ecore_evas_event_window_hide, NULL);
ecore_evas_event_handlers[15] = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL,
_ecore_evas_event_mouse_wheel, NULL);
+ if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
return _ecore_evas_init_count;
}
@@ -1040,6 +1054,7 @@
ecore_event_handler_del(ecore_evas_event_handlers[i]);
ecore_idle_enterer_del(ecore_evas_idle_enterer);
ecore_evas_idle_enterer = NULL;
+ if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
}
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
return _ecore_evas_init_count;
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs