summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-04-05 16:02:32 +0300
committerAvi Levin <avi.levin@samsung.com>2015-04-14 18:21:03 +0300
commitec9471cb9d102672a41b73e9b3b6d70b281a0058 (patch)
tree876c68e8922481624a9da34032846a94b6fea165
parent89809bdf551c4cad70eff972dff03a4a88977e0c (diff)
eo:callbacks find by event counterpartdevs/avilog/callbacks_by_counterpart
This branch is based on the assumption that we have only one legacy event per name and mostly no more than one regular that have same name = his counterpart. We save the counterpart in the legacy and mark if there is more than one.
-rw-r--r--src/lib/eo/Eo.h8
-rw-r--r--src/lib/eo/eo.c9
-rw-r--r--src/lib/eo/eo_base_class.c191
3 files changed, 187 insertions, 21 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index af787957d8..518e2669a4 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -257,8 +257,9 @@ struct _Eo_Event_Description
257{ 257{
258 const char *name; /**< name of the event. */ 258 const char *name; /**< name of the event. */
259 const char *doc; /**< Explanation about the event. */ 259 const char *doc; /**< Explanation about the event. */
260
261 Eina_Bool unfreezable; /**< Eina_True if the event cannot be frozen */ 260 Eina_Bool unfreezable; /**< Eina_True if the event cannot be frozen */
261 Eina_Bool is_more_events;
262 struct _Eo_Event_Description* counter;
262}; 263};
263 264
264/** 265/**
@@ -274,7 +275,7 @@ typedef struct _Eo_Event_Description Eo_Event_Description;
274 * @param doc Additional doc for the event. 275 * @param doc Additional doc for the event.
275 * @see Eo_Event_Description 276 * @see Eo_Event_Description
276 */ 277 */
277#define EO_EVENT_DESCRIPTION(name, doc) { name, doc, EINA_FALSE } 278#define EO_EVENT_DESCRIPTION(name, doc) { name, doc, EINA_FALSE , EINA_FALSE, NULL}
278 279
279/** 280/**
280 * @def EO_HOT_EVENT_DESCRIPTION(name, doc) 281 * @def EO_HOT_EVENT_DESCRIPTION(name, doc)
@@ -285,7 +286,7 @@ typedef struct _Eo_Event_Description Eo_Event_Description;
285 * @see Eo_Event_Description 286 * @see Eo_Event_Description
286 * @see EO_EVENT_DESCRIPTION 287 * @see EO_EVENT_DESCRIPTION
287 */ 288 */
288#define EO_HOT_EVENT_DESCRIPTION(name, doc) { name, doc, EINA_TRUE } 289#define EO_HOT_EVENT_DESCRIPTION(name, doc) { name, doc, EINA_TRUE ,EINA_FALSE, NULL}
289 290
290 291
291 292
@@ -960,6 +961,7 @@ typedef void (*eo_key_data_free_func)(void *);
960 */ 961 */
961EAPI const Eo_Event_Description *eo_base_legacy_only_event_description_get(const char *_event_name); 962EAPI const Eo_Event_Description *eo_base_legacy_only_event_description_get(const char *_event_name);
962 963
964EAPI void eo_base_regular_set_counter_description(const Eo_Event_Description *desc);
963/** 965/**
964 * @def EO_CALLBACK_PRIORITY_BEFORE 966 * @def EO_CALLBACK_PRIORITY_BEFORE
965 * Slightly more prioritized than default. 967 * Slightly more prioritized than default.
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 166e6385bf..9fdc3b981a 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1468,6 +1468,15 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
1468 1468
1469 DBG("Finished building class '%s'", klass->desc->name); 1469 DBG("Finished building class '%s'", klass->desc->name);
1470 1470
1471
1472
1473 const Eo_Event_Description **descs = klass->desc->events;
1474 /*add to the hash table*/
1475 for(; descs && *descs ;descs++){
1476 eo_base_regular_set_counter_description(*descs);
1477 DBG("adding event %s class %s\n", (*descs)->name, klass->desc->name);
1478 }
1479
1471 return _eo_class_id_get(klass); 1480 return _eo_class_id_get(klass);
1472} 1481}
1473 1482
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index d088d76736..fd0b9a0c63 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -25,8 +25,40 @@ typedef struct
25 unsigned short walking_list; 25 unsigned short walking_list;
26 unsigned short event_freeze_count; 26 unsigned short event_freeze_count;
27 Eina_Bool deletions_waiting : 1; 27 Eina_Bool deletions_waiting : 1;
28
29
30 unsigned int called_counter;
31 unsigned int callbacks_counter;
32 unsigned int called_loop_counter;
33 unsigned int called_inner_loop_counter;
34 unsigned int arrays_counter;
35 clock_t called_sum_clocks ;
36
37 unsigned int events_counter;
38 unsigned long long int have_events;
39
28} Eo_Base_Data; 40} Eo_Base_Data;
29 41
42
43static unsigned int called_counter=0;
44static unsigned int callbacks_counter=0;
45static unsigned int called_loop_counter=0;
46static unsigned int called_inner_loop_counter=0;
47
48static unsigned int arrays_counter=0;
49static unsigned int objects_counter=0;
50
51static clock_t called_sum_clocks =0;
52static clock_t start_clock =0;
53
54static unsigned int events_counter=0;
55
56
57static unsigned legacy_events_inserted=0;
58static unsigned regular_events_inserted=0;
59
60
61
30typedef struct 62typedef struct
31{ 63{
32 EINA_INLIST; 64 EINA_INLIST;
@@ -408,12 +440,15 @@ eo_base_legacy_only_event_description_get(const char *_event_name)
408{ 440{
409 Eina_Stringshare *event_name = eina_stringshare_add(_event_name); 441 Eina_Stringshare *event_name = eina_stringshare_add(_event_name);
410 Eo_Event_Description *event_desc = eina_hash_find(_legacy_events_hash, event_name); 442 Eo_Event_Description *event_desc = eina_hash_find(_legacy_events_hash, event_name);
411 if (!event_desc) 443 if (!event_desc || event_desc->doc!=_legacy_event_desc)
412 { 444 {
413 event_desc = calloc(1, sizeof(Eo_Event_Description)); 445 Eo_Event_Description *desc = calloc(1, sizeof(Eo_Event_Description));
414 event_desc->name = event_name; 446 desc->name = event_name;
415 event_desc->doc = _legacy_event_desc; 447 desc->doc = _legacy_event_desc;
416 eina_hash_add(_legacy_events_hash, event_name, event_desc); 448 desc->counter = event_desc;
449 desc->is_more_events = EINA_FALSE;
450 eina_hash_add(_legacy_events_hash, event_name, desc);
451 return desc;
417 } 452 }
418 else 453 else
419 { 454 {
@@ -427,10 +462,57 @@ static void
427_legacy_events_hash_free_cb(void *_desc) 462_legacy_events_hash_free_cb(void *_desc)
428{ 463{
429 Eo_Event_Description *desc = _desc; 464 Eo_Event_Description *desc = _desc;
430 eina_stringshare_del(desc->name); 465
431 free(desc); 466 if(desc->doc == _legacy_event_desc){
467
468 eina_stringshare_del(desc->name);
469
470 free(desc);
471 }
472 else {
473 Eina_Stringshare *event_name = eina_stringshare_add(desc->name);
474 eina_stringshare_del(event_name);//for the current share;
475 eina_stringshare_del(event_name);//for the shared key
476 }
432} 477}
433 478
479EAPI void
480eo_base_regular_set_counter_description(const Eo_Event_Description *desc)
481{
482 if(desc->doc == _legacy_event_desc)
483 /*its only for regular event. with legacy we handle
484 * in eo_base_legacy_only_event_description_get */
485 return;
486
487 Eina_Stringshare *event_name = eina_stringshare_add(desc->name);
488 Eo_Event_Description *event_desc = eina_hash_find(_legacy_events_hash, event_name);
489 if (!event_desc)
490 {
491
492 eina_hash_add(_legacy_events_hash, event_name, desc);
493 }
494 else
495 {
496 /*if more than one regular events with same name. only in rare occasions*/
497
498 if(event_desc->doc != _legacy_event_desc && event_desc!=desc){
499 /* we found a regular event. lets create a legacy events so we can mark
500 * that there are more events*/
501 Eo_Event_Description *new =
502 eo_base_legacy_only_event_description_get(event_desc->name);
503 new->is_more_events = EINA_TRUE;
504
505 }
506 else{
507 if( event_desc->counter && event_desc->counter!=desc)
508 event_desc ->is_more_events = EINA_TRUE;
509 else event_desc->counter = desc;
510 }
511 eina_stringshare_del(event_name);
512
513 }
514
515}
434/* EOF Legacy */ 516/* EOF Legacy */
435 517
436struct _Eo_Callback_Description 518struct _Eo_Callback_Description
@@ -541,6 +623,7 @@ _eo_callbacks_sorted_insert(Eo_Base_Data *pd, Eo_Callback_Description *cb)
541 cb->next = pd->callbacks; 623 cb->next = pd->callbacks;
542 pd->callbacks = cb; 624 pd->callbacks = cb;
543 } 625 }
626 pd->callbacks_counter++;//avi debug
544} 627}
545 628
546EOLIAN static void 629EOLIAN static void
@@ -639,10 +722,8 @@ _eo_base_event_callback_array_del(Eo *obj, Eo_Base_Data *pd,
639static Eina_Bool 722static Eina_Bool
640_cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b) 723_cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b)
641{ 724{
642 if (!a)
643 return EINA_FALSE;
644 725
645 /* If either is legacy, fallback to string comparison. */ 726
646 if ((a->doc == _legacy_event_desc) || (b->doc == _legacy_event_desc)) 727 if ((a->doc == _legacy_event_desc) || (b->doc == _legacy_event_desc))
647 { 728 {
648 /* Take stringshare shortcut if both are legacy */ 729 /* Take stringshare shortcut if both are legacy */
@@ -652,13 +733,30 @@ _cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b)
652 } 733 }
653 else 734 else
654 { 735 {
655 return !strcmp(a->name, b->name); 736 if (b->doc == _legacy_event_desc){
737 if( b->counter == b)/*b is legacy and a is not*/
738 return EINA_TRUE;
739 else if(b->is_more_events)
740 return !strcmp(a->name, b->name);
741
742 else return EINA_FALSE;
743 }
744 else{
745 if( a->counter == b)
746 return EINA_TRUE;
747 else if(a->is_more_events)
748 return !strcmp(a->name, b->name);
749
750 else return EINA_FALSE;
751
752 }
656 } 753 }
657 } 754 }
658 else 755 else
659 { 756 {
660 return (a == b); 757 return (a == b);
661 } 758 }
759
662} 760}
663 761
664EOLIAN static Eina_Bool 762EOLIAN static Eina_Bool
@@ -676,6 +774,11 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
676 _eo_ref(obj); 774 _eo_ref(obj);
677 pd->walking_list++; 775 pd->walking_list++;
678 776
777 pd->called_counter++;//avi debug
778
779 clock_t start_time = clock();
780
781
679 for (cb = pd->callbacks; cb; cb = cb->next) 782 for (cb = pd->callbacks; cb; cb = cb->next)
680 { 783 {
681 if (!cb->delete_me) 784 if (!cb->delete_me)
@@ -688,40 +791,48 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
688 { 791 {
689 if (!_cb_desc_match(it->desc, desc)) 792 if (!_cb_desc_match(it->desc, desc))
690 continue; 793 continue;
794
691 if (!it->desc->unfreezable && 795 if (!it->desc->unfreezable &&
692 (event_freeze_count || pd->event_freeze_count)) 796 (event_freeze_count || pd->event_freeze_count))
693 continue; 797 continue;
694 798
799 unsigned int before_func=clock();
695 /* Abort callback calling if the func says so. */ 800 /* Abort callback calling if the func says so. */
696 if (!it->func((void *) cb->func_data, obj_id, desc, 801 if (!it->func((void *) cb->func_data, obj_id, desc,
697 (void *) event_info)) 802 (void *) event_info))
698 { 803 {
699 ret = EINA_FALSE; 804 ret = EINA_FALSE;
805 start_time+=clock()-before_func;
700 goto end; 806 goto end;
701 } 807 }
808 start_time+=clock()-before_func;
702 } 809 }
703 } 810 }
704 else 811 else
705 { 812 {
706 if (!_cb_desc_match(cb->items.item.desc, desc)) 813 if (!_cb_desc_match(cb->items.item.desc, desc))
707 continue; 814 continue;
708 if ((!cb->items.item.desc
709 || !cb->items.item.desc->unfreezable) &&
710 (event_freeze_count || pd->event_freeze_count))
711 continue;
712 815
816 if ((!cb->items.item.desc
817 || !cb->items.item.desc->unfreezable) &&
818 (event_freeze_count || pd->event_freeze_count))
819 continue;
820 unsigned int before_func=clock();
713 /* Abort callback calling if the func says so. */ 821 /* Abort callback calling if the func says so. */
714 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc, 822 if (!cb->items.item.func((void *) cb->func_data, obj_id, desc,
715 (void *) event_info)) 823 (void *) event_info))
716 { 824 {
717 ret = EINA_FALSE; 825 ret = EINA_FALSE;
826 start_time+=clock()-before_func;
718 goto end; 827 goto end;
719 } 828 }
829 start_time+=clock()-before_func;
720 } 830 }
721 } 831 }
722 } 832 }
723 833
724end: 834end:
835 pd->called_sum_clocks +=clock()-start_time;//avi dbg
725 pd->walking_list--; 836 pd->walking_list--;
726 _eo_callbacks_clear(pd); 837 _eo_callbacks_clear(pd);
727 _eo_unref(obj); 838 _eo_unref(obj);
@@ -965,11 +1076,40 @@ EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE;
965/* EO_BASE_CLASS stuff */ 1076/* EO_BASE_CLASS stuff */
966#define MY_CLASS EO_BASE_CLASS 1077#define MY_CLASS EO_BASE_CLASS
967 1078
1079
1080
1081static __attribute__((destructor)) void finish(void)
1082{
1083 printf("calbacks stats-All objects!: num objects=%u total time=%f \
1084 called cal times= %u called loops=%u called clocks=%f called sec=%f \
1085 callbacks count=%u events counter=%u legacy_events_inserted=%u regular_events_inserted=%u \n",
1086 objects_counter,(double)(clock()-start_clock)/CLOCKS_PER_SEC, called_counter,
1087 called_loop_counter,(double)called_sum_clocks,
1088 (double)called_sum_clocks/CLOCKS_PER_SEC, callbacks_counter ,
1089 events_counter, legacy_events_inserted, regular_events_inserted
1090 );//avi debug
1091
1092}
1093
1094
968EOLIAN static void 1095EOLIAN static void
969_eo_base_constructor(Eo *obj, Eo_Base_Data *pd EINA_UNUSED) 1096_eo_base_constructor(Eo *obj, Eo_Base_Data *pd EINA_UNUSED)
970{ 1097{
971 DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); 1098 DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
972 1099
1100
1101
1102 pd->called_counter=0;
1103 pd->callbacks_counter=0;
1104 pd-> called_loop_counter=0;
1105
1106 pd-> called_loop_counter=0;
1107
1108 pd-> called_sum_clocks =0;
1109 pd->events_counter=0;
1110 pd->have_events = 0;
1111
1112
973 _eo_condtor_done(obj); 1113 _eo_condtor_done(obj);
974} 1114}
975 1115
@@ -980,6 +1120,21 @@ _eo_base_destructor(Eo *obj, Eo_Base_Data *pd)
980 1120
981 DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); 1121 DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
982 1122
1123 if( pd->callbacks_counter>0 ){//only with atleast one calllbacks
1124
1125 called_counter+=pd->called_counter;
1126 callbacks_counter+=pd->callbacks_counter;
1127 called_loop_counter+= pd->called_loop_counter;
1128 arrays_counter+=pd->arrays_counter;
1129 called_inner_loop_counter+=pd->called_inner_loop_counter;
1130 called_sum_clocks+=pd-> called_sum_clocks;
1131 events_counter+=pd->events_counter;
1132
1133 objects_counter++;
1134 }
1135
1136
1137
983 EINA_LIST_FREE(pd->children, child) 1138 EINA_LIST_FREE(pd->children, child)
984 eo_do(child, eo_parent_set(NULL)); 1139 eo_do(child, eo_parent_set(NULL));
985 1140