summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <m.blumenkran@samsung.com>2013-09-25 14:16:57 +0100
committerMike Blumenkrantz <m.blumenkran@samsung.com>2013-09-25 14:16:57 +0100
commit0d7f92787a15062c944ec2e79b54da52bf7b4420 (patch)
tree1c6a4fabdb2278f875117c77b440fd5c174f06f3
parent5fd762d955c8c77f38e488455e0c7dc4a3bd113d (diff)
add render callbacks, calculate cpu time
-rw-r--r--compbench_preload.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/compbench_preload.c b/compbench_preload.c
index 48747a7..27da1ea 100644
--- a/compbench_preload.c
+++ b/compbench_preload.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4#include <dlfcn.h> 4#include <dlfcn.h>
5#include <execinfo.h> 5#include <execinfo.h>
6#include <time.h>
6#include <Ecore_Evas.h> 7#include <Ecore_Evas.h>
7#include <Evas.h> 8#include <Evas.h>
8#include <Eeze.h> 9#include <Eeze.h>
@@ -16,6 +17,8 @@ static Eina_Hash *batteries = NULL;
16static ulonglong total_charge_start = 0; 17static ulonglong total_charge_start = 0;
17static ulonglong total_charge_current = 0; 18static ulonglong total_charge_current = 0;
18 19
20static clock_t render_pre = 0, render_post = 0;
21
19typedef struct Battery_Info 22typedef struct Battery_Info
20{ 23{
21 Eina_Stringshare *syspath; 24 Eina_Stringshare *syspath;
@@ -41,15 +44,32 @@ _bat_charge_get(const char *syspath)
41static void 44static void
42_comp_post_render(void *data, Evas *e, Evas_Event_Render_Post *ev) 45_comp_post_render(void *data, Evas *e, Evas_Event_Render_Post *ev)
43{ 46{
47 double cpu_time_used;
44 48
49 render_post = clock();
50 cpu_time_used = ((double) (render_post - render_pre)) / CLOCKS_PER_SEC;
51}
52
53static void
54_comp_pre_render(void *data, Evas *e, void *ev EINA_UNUSED)
55{
56 double cpu_time_used;
57
58 render_pre = clock();
59 if (render_post) cpu_time_used = ((double) (render_pre - render_post)) / CLOCKS_PER_SEC;
45} 60}
46 61
47static void 62static void
48_bat_watch_cb(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch EINA_UNUSED) 63_bat_watch_cb(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
49{ 64{
50 ulonglong charge; 65 ulonglong charge;
66 Battery_Info *bi;
51 67
52 charge = _bat_charge_get(syspath); 68 charge = _bat_charge_get(syspath);
69 bi = eina_hash_find(batteries, syspath);
70 total_charge_current -= bi->charge_current;
71 bi->charge_current = charge;
72 total_charge_current += bi->charge_current;
53} 73}
54 74
55static void 75static void
@@ -64,10 +84,14 @@ bat_info_free(Battery_Info *bi)
64EAPI void 84EAPI void
65ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync) 85ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync)
66{ 86{
87 Evas *e;
67 void (*_ecore_evas_comp_sync_set)(Ecore_Evas *, Eina_Bool) = dlsym(RTLD_NEXT, __func__); 88 void (*_ecore_evas_comp_sync_set)(Ecore_Evas *, Eina_Bool) = dlsym(RTLD_NEXT, __func__);
68 89
69 if (comp_ee) return; 90 if (comp_ee) return;
70 comp_ee = ee; 91 comp_ee = ee;
92 e = ecore_evas_get(ee);
93 evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, _comp_post_render, NULL);
94 evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, _comp_pre_render, NULL);
71 95
72 _ecore_evas_comp_sync_set(ee, do_sync); 96 _ecore_evas_comp_sync_set(ee, do_sync);
73} 97}