ck_ht: Add ck_ht_stat function.

This can be used to expose certain performance metrics.
ck_pring
Samy Al Bahra 13 years ago
parent fe41e4082b
commit adaf20b31c

@ -99,6 +99,11 @@ struct ck_ht {
};
typedef struct ck_ht ck_ht_t;
struct ck_ht_stat {
uint64_t probe_maximum;
uint64_t n_entries;
};
struct ck_ht_iterator {
struct ck_ht_entry *current;
uint64_t offset;
@ -237,6 +242,7 @@ ck_ht_entry_value_direct(ck_ht_entry_t *entry)
*/
bool ck_ht_next(ck_ht_t *, ck_ht_iterator_t *, ck_ht_entry_t **entry);
void ck_ht_stat(ck_ht_t *, struct ck_ht_stat *);
void ck_ht_hash(ck_ht_hash_t *, ck_ht_t *, const void *, uint16_t);
void ck_ht_hash_direct(ck_ht_hash_t *, ck_ht_t *, uintptr_t);
bool ck_ht_init(ck_ht_t *, enum ck_ht_mode, ck_ht_hash_cb_t *, struct ck_malloc *, uint64_t, uint64_t);

@ -176,6 +176,7 @@ main(int argc, char *argv[])
unsigned int d = 0;
uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng;
char **t;
struct ck_ht_stat st;
r = 20;
s = 8;
@ -218,9 +219,10 @@ main(int argc, char *argv[])
for (i = 0; i < keys_length; i++)
d += table_insert(keys[i]) == false;
ck_ht_stat(&ht, &st);
fprintf(stderr, "# %zu entries stored and %u duplicates.\n",
table_count(), d);
fprintf(stderr, "# %zu entries stored, %u duplicates, %" PRIu64 " probe.\n",
table_count(), d, st.probe_maximum);
fprintf(stderr, "# reverse_insertion serial_insertion random_insertion serial_replace reverse_get serial_get random_get serial_remove negative_get\n\n");

@ -74,6 +74,17 @@ struct ck_ht_map {
struct ck_ht_entry *entries;
};
void
ck_ht_stat(struct ck_ht *table,
struct ck_ht_stat *st)
{
struct ck_ht_map *map = table->map;
st->n_entries = map->n_entries;
st->probe_maximum = map->probe_maximum;
return;
}
void
ck_ht_hash(struct ck_ht_hash *h,
struct ck_ht *table,

Loading…
Cancel
Save