cedric pushed a commit to branch master.

commit 923d59204f0c9f0570e9e173e2b1368ae4106641
Author: Cedric BAIL <[email protected]>
Date:   Wed Mar 20 17:37:40 2013 +0900

    elementary: add infrastructure to track startup time.
    
    Set ELM_FIRST_FRAME to :
    * D or E: for exit
    * A: for abort
    * T: to display the time since entering main();
---
 src/bin/quicklaunch.c |  2 ++
 src/lib/elm_general.h |  6 ++++--
 src/lib/elm_win.c     | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/bin/quicklaunch.c b/src/bin/quicklaunch.c
index e84612b..0bd246c 100644
--- a/src/bin/quicklaunch.c
+++ b/src/bin/quicklaunch.c
@@ -103,6 +103,8 @@ handle_run(int fd, unsigned long bytes)
    int argc, envnum;
    unsigned long off;
 
+   _elm_startup_time = ecore_time_unix_get();
+
    buf = alloca(bytes);
    if (read(fd, buf, bytes) != (int)bytes)
      {
diff --git a/src/lib/elm_general.h b/src/lib/elm_general.h
index b87481b..9cfee65 100644
--- a/src/lib/elm_general.h
+++ b/src/lib/elm_general.h
@@ -117,10 +117,12 @@ typedef enum
 
 typedef Eina_Bool             (*Elm_Event_Cb)(void *data, Evas_Object *obj, 
Evas_Object *src, Evas_Callback_Type type, void *event_info); /**< Function 
prototype definition for callbacks on input events happening on Elementary 
widgets. @a data will receive the user data pointer passed to 
elm_object_event_callback_add(). @a src will be a pointer to the widget on 
which the input event took place. @a type will get the type of this event and 
@a event_info, the struct with details on this event. */
 
+extern EAPI double _elm_startup_time;
+
 #ifndef ELM_LIB_QUICKLAUNCH
-#define ELM_MAIN() int main(int argc, char **argv) {elm_init(argc, argv); 
return elm_main(argc, argv); } /**< macro to be used after the elm_main() 
function */
+#define ELM_MAIN() int main(int argc, char **argv) { _elm_startup_time = 
ecore_time_unix_get(); elm_init(argc, argv); return elm_main(argc, argv); } 
/**< macro to be used after the elm_main() function */
 #else
-#define ELM_MAIN() int main(int argc, char **argv) {return 
elm_quicklaunch_fallback(argc, argv); } /**< macro to be used after the 
elm_main() function */
+#define ELM_MAIN() int main(int argc, char **argv) { _elm_startup_time = 
ecore_time_unix_get(); return elm_quicklaunch_fallback(argc, argv); } /**< 
macro to be used after the elm_main() function */
 #endif
 
 /**************************************************************************/
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 9d708e6..bc9b35c 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -213,6 +213,26 @@ _elm_win_on_resize_obj_changed_size_hints(void *data,
                                           Evas_Object *obj,
                                           void *event_info);
 
+EAPI double _elm_startup_time = 0;
+
+static void
+_elm_win_first_frame_do(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void 
*event_info EINA_UNUSED)
+{
+   double end = ecore_time_unix_get();
+   char *first = getenv("ELM_FIRST_FRAME");
+
+   switch (*first)
+     {
+      case 'A': abort();
+      case 'E':
+      case 'D': exit(-1);
+      case 'T': fprintf(stderr, "Startup time: '%f' - '%f' = '%f'\n", end, 
_elm_startup_time, end - _elm_startup_time);
+         break;
+     }
+
+   evas_event_callback_del_full(e, EVAS_CALLBACK_RENDER_POST, 
_elm_win_first_frame_do, NULL);
+}
+
 static void
 _elm_win_state_eval(void *data __UNUSED__)
 {
@@ -2784,6 +2804,10 @@ _win_constructor(Eo *obj, void *_pd, va_list *list)
          evas_obj_type_set(MY_CLASS_NAME),
          evas_obj_smart_callbacks_descriptions_set(_smart_callbacks, NULL));
 
+   if (getenv("ELM_FIRST_FRAME"))
+     evas_event_callback_add(ecore_evas_get(tmp_sd.ee), 
EVAS_CALLBACK_RENDER_POST,
+                            _elm_win_first_frame_do, NULL);
+
    /* copying possibly altered fields back */
 #define SD_CPY(_field)             \
   do                               \

-- 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

Reply via email to