The test cases have been carefully crafted so that we do the same amount of "overhead" operations in each case. Earlier, with no mutations, the number of random number generations was different for hmap and cmap test cases. hmap test was also missing an ignore() call. Now the numbers look like this:
$ tests/ovstest test-cmap benchmark 2000000 8 0 Benchmarking with n=2000000, 8 threads, 0.00% mutations: cmap insert: 597 ms cmap iterate: 65 ms cmap search: 299 ms cmap destroy: 251 ms hmap insert: 243 ms hmap iterate: 201 ms hmap search: 299 ms hmap destroy: 202 ms So it seems search on cmap can be as fast as on hmap in the single-threaded case. Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- tests/test-cmap.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/test-cmap.c b/tests/test-cmap.c index de48853..3838e99 100644 --- a/tests/test-cmap.c +++ b/tests/test-cmap.c @@ -291,17 +291,23 @@ search_cmap(void *aux_) struct cmap_aux *aux = aux_; size_t i; - for (i = 0; i < n_elems; i++) { - struct element *e; + if (mutation_frac) { + for (i = 0; i < n_elems; i++) { + struct element *e; - if (random_uint32() < mutation_frac) { - ovs_mutex_lock(&aux->mutex); - e = find(aux->cmap, i); - if (e) { - cmap_remove(aux->cmap, &e->node, hash_int(e->value, 0)); + if (random_uint32() < mutation_frac) { + ovs_mutex_lock(&aux->mutex); + e = find(aux->cmap, i); + if (e) { + cmap_remove(aux->cmap, &e->node, hash_int(e->value, 0)); + } + ovs_mutex_unlock(&aux->mutex); + } else { + ignore(find(aux->cmap, i)); } - ovs_mutex_unlock(&aux->mutex); - } else { + } + } else { + for (i = 0; i < n_elems; i++) { ignore(find(aux->cmap, i)); } } @@ -392,8 +398,8 @@ search_hmap(void *aux_) struct hmap_aux *aux = aux_; size_t i; - for (i = 0; i < n_elems; i++) { - if (mutation_frac) { + if (mutation_frac) { + for (i = 0; i < n_elems; i++) { if (random_uint32() < mutation_frac) { struct helement *e; @@ -408,8 +414,10 @@ search_hmap(void *aux_) ignore(hfind(aux->hmap, i)); fat_rwlock_unlock(&aux->fatlock); } - } else { - hfind(aux->hmap, i); + } + } else { + for (i = 0; i < n_elems; i++) { + ignore(hfind(aux->hmap, i)); } } return NULL; -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev