else return strcmp(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
}
-#define dictionary_name_value_index_add_nolock(dict, nv) do { (dict)->inserts++; avl_insert(&((dict)->values_index), (avl *)(nv)); } while(0)
-#define dictionary_name_value_index_del_nolock(dict, nv) do { (dict)->deletes++; avl_remove(&(dict->values_index), (avl *)(nv)); } while(0)
+#define dictionary_name_value_index_add_nolock(dict, nv) do { NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict); avl_insert(&((dict)->values_index), (avl *)(nv)); } while(0)
+#define dictionary_name_value_index_del_nolock(dict, nv) do { NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict); avl_remove(&(dict->values_index), (avl *)(nv)); } while(0)
static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *dict, const char *name, uint32_t hash) {
NAME_VALUE tmp;
tmp.hash = (hash)?hash:simple_hash(name);
tmp.name = (char *)name;
- dict->searches++;
+ NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict);
return (NAME_VALUE *)avl_search(&(dict->values_index), (avl *) &tmp);
}
// index it
dictionary_name_value_index_add_nolock(dict, nv);
- dict->entries++;
+ NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict);
return nv;
}
dictionary_name_value_index_del_nolock(dict, nv);
- dict->entries--;
+ NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict);
if(!(dict->flags & DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE)) {
debug(D_REGISTRY, "Dictionary freeing value of '%s'", nv->name);
uint8_t flags;
+#ifdef NETDATA_DICTIONARY_WITH_STATISTICS
unsigned long long inserts;
unsigned long long deletes;
unsigned long long searches;
unsigned long long entries;
+#endif /* NETDATA_DICTIONARY_WITH_STATISTICS */
pthread_rwlock_t rwlock;
} DICTIONARY;
+#ifdef NETDATA_DICTIONARY_WITH_STATISTICS
+#define NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict) (dict)->inserts++
+#define NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict) (dict)->deletes++
+#define NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict) (dict)->searches++
+#define NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict) (dict)->entries++
+#define NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict) (dict)->entries--
+#else /* NETDATA_DICTIONARY_WITH_STATISTICS */
+#define NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict)
+#endif /* NETDATA_DICTIONARY_WITH_STATISTICS */
+
#define DICTIONARY_FLAG_DEFAULT 0x00000000
#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001
#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002