MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_average_table_utilization

Function test_average_table_utilization

dpdk/app/test/test_efd.c:332–391  ·  view source on GitHub ↗

* Test to see the average table utilization (entries added/max entries) * before hitting a random entry that cannot be added */

Source from the content-addressed store, hash-verified

330 * before hitting a random entry that cannot be added
331 */
332static int test_average_table_utilization(void)
333{
334 struct rte_efd_table *handle = NULL;
335 uint32_t num_rules_in = TABLE_SIZE;
336 uint8_t simple_key[EFD_TEST_KEY_LEN];
337 unsigned int i, j;
338 unsigned int added_keys, average_keys_added = 0;
339
340 printf("Evaluating table utilization and correctness, please wait\n");
341 fflush(stdout);
342
343 for (j = 0; j < ITERATIONS; j++) {
344 handle = rte_efd_create("test_efd", num_rules_in,
345 EFD_TEST_KEY_LEN, efd_get_all_sockets_bitmask(),
346 test_socket_id);
347 if (handle == NULL) {
348 printf("efd table creation failed\n");
349 return -1;
350 }
351
352 unsigned int succeeded = 0;
353 unsigned int lost_keys = 0;
354
355 /* Add random entries until key cannot be added */
356 for (added_keys = 0; added_keys < num_rules_in; added_keys++) {
357
358 for (i = 0; i < EFD_TEST_KEY_LEN; i++)
359 simple_key[i] = rte_rand() & 0xFF;
360
361 efd_value_t val = simple_key[0];
362
363 if (rte_efd_update(handle, test_socket_id, simple_key,
364 val))
365 break; /* continue;*/
366 if (rte_efd_lookup(handle, test_socket_id, simple_key)
367 != val)
368 lost_keys++;
369 else
370 succeeded++;
371 }
372
373 average_keys_added += succeeded;
374
375 /* Reset the table */
376 rte_efd_free(handle);
377
378 /* Print progress on operations */
379 printf("Added %10u Succeeded %10u Lost %10u\n",
380 added_keys, succeeded, lost_keys);
381 fflush(stdout);
382 }
383
384 average_keys_added /= ITERATIONS;
385
386 printf("\nAverage table utilization = %.2f%% (%u/%u)\n",
387 ((double) average_keys_added / num_rules_in * 100),
388 average_keys_added, num_rules_in);
389

Callers 1

test_efdFunction · 0.70

Calls 7

rte_efd_createFunction · 0.85
rte_randFunction · 0.85
rte_efd_updateFunction · 0.85
rte_efd_lookupFunction · 0.85
rte_efd_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected