1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add debug_counters to check details.

add debug_counters to check the Hash object statistics.
This commit is contained in:
Koichi Sasada 2019-08-02 14:59:29 +09:00
parent a0980f2446
commit e03b3b4ae0
2 changed files with 36 additions and 12 deletions

View file

@ -217,9 +217,14 @@ RB_DEBUG_COUNTER(obj_ary_shared)
RB_DEBUG_COUNTER(obj_ary_shared_root_occupied)
RB_DEBUG_COUNTER(obj_hash_empty)
RB_DEBUG_COUNTER(obj_hash_1_4)
RB_DEBUG_COUNTER(obj_hash_1)
RB_DEBUG_COUNTER(obj_hash_2)
RB_DEBUG_COUNTER(obj_hash_3)
RB_DEBUG_COUNTER(obj_hash_4)
RB_DEBUG_COUNTER(obj_hash_5_8)
RB_DEBUG_COUNTER(obj_hash_g8)
RB_DEBUG_COUNTER(obj_hash_null)
RB_DEBUG_COUNTER(obj_hash_ar)
RB_DEBUG_COUNTER(obj_hash_st)
RB_DEBUG_COUNTER(obj_hash_transient)

41
gc.c
View file

@ -2448,21 +2448,40 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
case T_HASH:
#if USE_DEBUG_COUNTER
if (RHASH_SIZE(obj) > 8) {
RB_DEBUG_COUNTER_INC(obj_hash_g8);
}
else if (RHASH_SIZE(obj) > 4) {
RB_DEBUG_COUNTER_INC(obj_hash_5_8);
}
else if (RHASH_SIZE(obj) > 0) {
RB_DEBUG_COUNTER_INC(obj_hash_1_4);
}
else {
switch RHASH_SIZE(obj) {
case 0:
RB_DEBUG_COUNTER_INC(obj_hash_empty);
break;
case 1:
RB_DEBUG_COUNTER_INC(obj_hash_1);
break;
case 2:
RB_DEBUG_COUNTER_INC(obj_hash_2);
break;
case 3:
RB_DEBUG_COUNTER_INC(obj_hash_3);
break;
case 4:
RB_DEBUG_COUNTER_INC(obj_hash_4);
break;
case 5:
case 6:
case 7:
case 8:
RB_DEBUG_COUNTER_INC(obj_hash_5_8);
break;
default:
GC_ASSERT(RHASH_SIZE(obj) > 8);
RB_DEBUG_COUNTER_INC(obj_hash_g8);
}
if (RHASH_AR_TABLE_P(obj)) {
RB_DEBUG_COUNTER_INC(obj_hash_ar);
if (RHASH_AR_TABLE(obj) == NULL) {
RB_DEBUG_COUNTER_INC(obj_hash_null);
}
else {
RB_DEBUG_COUNTER_INC(obj_hash_ar);
}
}
else {
RB_DEBUG_COUNTER_INC(obj_hash_st);