ecore: report startup time of the main loop with EFL_FIRST_LOOP environment variable.
authorCedric BAIL <cedric@osg.samsung.com>
Mon, 6 Nov 2017 19:06:21 +0000 (11:06 -0800)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 8 Nov 2017 00:08:39 +0000 (16:08 -0800)
src/lib/ecore/ecore.c

index 00bf640..5ac30d6 100644 (file)
@@ -202,6 +202,25 @@ ecore_system_modules_unload(void)
      }
 }
 
+static void
+_efl_first_loop_iterate(void *data, const Efl_Event *event)
+{
+   double end = ecore_time_unix_get();
+   char *first = data;
+
+   switch (*first)
+     {
+      case 'A': abort();
+      case 'E':
+      case 'D': exit(-1);
+      case 'T': fprintf(stderr, "Loop started: '%f' - '%f' = '%f' sec\n", end, _efl_startup_time, end - _efl_startup_time);
+         break;
+     }
+
+   efl_event_callback_del(event->object, EFL_LOOP_EVENT_RESUME,
+                          _efl_first_loop_iterate, data);
+}
+
 EAPI void
 ecore_app_no_system_modules(void)
 {
@@ -326,6 +345,12 @@ ecore_init(void)
    if (!_no_system_modules)
      ecore_system_modules_load();
 
+   if (getenv("EFL_FIRST_LOOP"))
+     efl_event_callback_add(ecore_main_loop_get(),
+                            EFL_LOOP_EVENT_RESUME,
+                            _efl_first_loop_iterate,
+                            getenv("EFL_FIRST_LOOP"));
+
    _ecore_init_count_threshold = _ecore_init_count;
 
    eina_log_timing(_ecore_log_dom,