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

Function test_average_table_utilization

dpdk/app/test/test_hash.c:1442–1523  ·  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

1440 * before hitting a random entry that cannot be added
1441 */
1442static int test_average_table_utilization(uint32_t ext_table)
1443{
1444 struct rte_hash *handle;
1445 uint8_t simple_key[MAX_KEYSIZE];
1446 unsigned i, j;
1447 unsigned added_keys, average_keys_added = 0;
1448 int ret;
1449 unsigned int cnt;
1450
1451 printf("\n# Running test to determine average utilization"
1452 "\n before adding elements begins to fail\n");
1453 if (ext_table)
1454 printf("ext table is enabled\n");
1455 else
1456 printf("ext table is disabled\n");
1457
1458 printf("Measuring performance, please wait");
1459 fflush(stdout);
1460 ut_params.entries = 1 << 16;
1461 ut_params.name = "test_average_utilization";
1462 ut_params.hash_func = rte_jhash;
1463 if (ext_table)
1464 ut_params.extra_flag |= RTE_HASH_EXTRA_FLAGS_EXT_TABLE;
1465 else
1466 ut_params.extra_flag &= ~RTE_HASH_EXTRA_FLAGS_EXT_TABLE;
1467
1468 handle = rte_hash_create(&ut_params);
1469
1470 RETURN_IF_ERROR(handle == NULL, "hash creation failed");
1471
1472 for (j = 0; j < ITERATIONS; j++) {
1473 ret = 0;
1474 /* Add random entries until key cannot be added */
1475 for (added_keys = 0; ret >= 0; added_keys++) {
1476 for (i = 0; i < ut_params.key_len; i++)
1477 simple_key[i] = rte_rand() % 255;
1478 ret = rte_hash_add_key(handle, simple_key);
1479 if (ret < 0)
1480 break;
1481 }
1482
1483 if (ret != -ENOSPC) {
1484 printf("Unexpected error when adding keys\n");
1485 rte_hash_free(handle);
1486 return -1;
1487 }
1488
1489 cnt = rte_hash_count(handle);
1490 if (cnt != added_keys) {
1491 printf("rte_hash_count returned wrong value %u, %u,"
1492 "%u\n", j, added_keys, cnt);
1493 rte_hash_free(handle);
1494 return -1;
1495 }
1496 if (ext_table) {
1497 if (cnt != ut_params.entries) {
1498 printf("rte_hash_count returned wrong value "
1499 "%u, %u, %u\n", j, added_keys, cnt);

Callers 1

test_hashFunction · 0.70

Calls 7

rte_hash_createFunction · 0.85
rte_randFunction · 0.85
rte_hash_add_keyFunction · 0.85
rte_hash_freeFunction · 0.85
rte_hash_countFunction · 0.85
rte_hash_resetFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected