aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra/vppinfra/test_qhash.c
diff options
context:
space:
mode:
Diffstat (limited to 'vppinfra/vppinfra/test_qhash.c')
-rw-r--r--vppinfra/vppinfra/test_qhash.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/vppinfra/vppinfra/test_qhash.c b/vppinfra/vppinfra/test_qhash.c
index 8d0b8b7e47b..fdbf0bbebb0 100644
--- a/vppinfra/vppinfra/test_qhash.c
+++ b/vppinfra/vppinfra/test_qhash.c
@@ -18,24 +18,25 @@
#include <vppinfra/random.h>
#include <vppinfra/time.h>
-typedef struct {
+typedef struct
+{
u32 n_iter, seed, n_keys, n_hash_keys, verbose;
u32 max_vector;
- uword * hash;
+ uword *hash;
- uword * keys_in_hash_bitmap;
+ uword *keys_in_hash_bitmap;
- u32 * qhash;
+ u32 *qhash;
- uword * keys;
+ uword *keys;
- uword * lookup_keys;
- uword * lookup_key_indices;
- u32 * lookup_results;
+ uword *lookup_keys;
+ uword *lookup_key_indices;
+ u32 *lookup_results;
- u32 * get_multiple_results;
+ u32 *get_multiple_results;
clib_time_t time;
@@ -49,8 +50,8 @@ typedef struct {
clib_error_t *
test_qhash_main (unformat_input_t * input)
{
- clib_error_t * error = 0;
- test_qhash_main_t _tm, * tm = &_tm;
+ clib_error_t *error = 0;
+ test_qhash_main_t _tm, *tm = &_tm;
uword i, iter;
memset (tm, 0, sizeof (tm[0]));
@@ -81,7 +82,7 @@ test_qhash_main (unformat_input_t * input)
}
}
- if (! tm->seed)
+ if (!tm->seed)
tm->seed = random_default_seed ();
clib_time_init (&tm->time);
@@ -94,13 +95,13 @@ test_qhash_main (unformat_input_t * input)
for (i = 0; i < vec_len (tm->keys); i++)
tm->keys[i] = random_uword (&tm->seed);
- if (! tm->n_hash_keys)
+ if (!tm->n_hash_keys)
tm->n_hash_keys = 2 * max_pow2 (tm->n_keys);
tm->n_hash_keys = clib_max (tm->n_keys, tm->n_hash_keys);
qhash_resize (tm->qhash, tm->n_hash_keys);
{
- qhash_t * h = qhash_header (tm->qhash);
+ qhash_t *h = qhash_header (tm->qhash);
int i;
for (i = 0; i < ARRAY_LEN (h->hash_seeds); i++)
h->hash_seeds[i] = random_uword (&tm->seed);
@@ -112,7 +113,7 @@ test_qhash_main (unformat_input_t * input)
for (iter = 0; iter < tm->n_iter; iter++)
{
- uword * p, j, n, is_set;
+ uword *p, j, n, is_set;
n = tm->max_vector;
@@ -143,8 +144,7 @@ test_qhash_main (unformat_input_t * input)
else
tm->hash_unset_time += t[1] - t[0];
tm->keys_in_hash_bitmap
- = clib_bitmap_set (tm->keys_in_hash_bitmap, i,
- is_set);
+ = clib_bitmap_set (tm->keys_in_hash_bitmap, i, is_set);
j++;
}
}
@@ -191,7 +191,7 @@ test_qhash_main (unformat_input_t * input)
os_panic ();
{
- qhash_t * h;
+ qhash_t *h;
uword i, k, l, count;
h = qhash_header (tm->qhash);
@@ -210,13 +210,15 @@ test_qhash_main (unformat_input_t * input)
os_panic ();
{
- u32 * tmp = 0;
+ u32 *tmp = 0;
+ /* *INDENT-OFF* */
hash_foreach (k, l, h->overflow_hash, ({
j = qhash_hash_mix (h, k) / QHASH_KEYS_PER_BUCKET;
vec_validate (tmp, j);
tmp[j] += 1;
}));
+ /* *INDENT-ON* */
for (k = 0; k < vec_len (tmp); k++)
{
@@ -256,7 +258,7 @@ test_qhash_main (unformat_input_t * input)
{
if (p[0] != i)
os_panic ();
- if (* vec_elt_at_index (tm->qhash, r) != i)
+ if (*vec_elt_at_index (tm->qhash, r) != i)
os_panic ();
}
else
@@ -276,8 +278,7 @@ test_qhash_main (unformat_input_t * input)
fformat (stderr, "%d iter %.6e overflow, %.4f ave. elts\n",
tm->n_iter,
- tm->overflow_fraction / tm->n_iter,
- tm->ave_elts / tm->n_iter);
+ tm->overflow_fraction / tm->n_iter, tm->ave_elts / tm->n_iter);
tm->get_time /= tm->n_iter * vec_len (tm->keys);
tm->hash_get_time /= tm->n_iter * vec_len (tm->keys);
@@ -287,27 +288,28 @@ test_qhash_main (unformat_input_t * input)
tm->hash_set_time /= tm->set_count;
tm->hash_unset_time /= tm->unset_count;
- fformat (stderr, "get/set/unset clocks %.2e %.2e %.2e clib %.2e %.2e %.2e ratio %.2f %.2f %.2f\n",
+ fformat (stderr,
+ "get/set/unset clocks %.2e %.2e %.2e clib %.2e %.2e %.2e ratio %.2f %.2f %.2f\n",
tm->get_time * tm->time.clocks_per_second,
tm->set_time * tm->time.clocks_per_second,
tm->unset_time * tm->time.clocks_per_second,
tm->hash_get_time * tm->time.clocks_per_second,
tm->hash_set_time * tm->time.clocks_per_second,
tm->hash_unset_time * tm->time.clocks_per_second,
- tm->hash_get_time / tm->get_time,
- tm->hash_set_time / tm->set_time,
+ tm->hash_get_time / tm->get_time, tm->hash_set_time / tm->set_time,
tm->hash_unset_time / tm->unset_time);
-
- done:
+
+done:
return error;
}
#ifdef CLIB_UNIX
-int main (int argc, char * argv[])
+int
+main (int argc, char *argv[])
{
unformat_input_t i;
- clib_error_t * error;
+ clib_error_t *error;
unformat_init_command_line (&i, argv);
error = test_qhash_main (&i);
@@ -321,3 +323,11 @@ int main (int argc, char * argv[])
return 0;
}
#endif /* CLIB_UNIX */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */