| 52 | } |
| 53 | |
| 54 | static int |
| 55 | test_lpm6_perf(void) |
| 56 | { |
| 57 | struct rte_lpm6 *lpm = NULL; |
| 58 | struct rte_lpm6_config config; |
| 59 | uint64_t begin, total_time; |
| 60 | unsigned i, j; |
| 61 | uint32_t next_hop_add = 0xAA, next_hop_return = 0; |
| 62 | int status = 0; |
| 63 | int64_t count = 0; |
| 64 | |
| 65 | config.max_rules = 1000000; |
| 66 | config.number_tbl8s = NUMBER_TBL8S; |
| 67 | config.flags = 0; |
| 68 | |
| 69 | rte_srand(rte_rdtsc()); |
| 70 | |
| 71 | printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES); |
| 72 | |
| 73 | print_route_distribution(large_route_table, (uint32_t) NUM_ROUTE_ENTRIES); |
| 74 | |
| 75 | /* Only generate IPv6 address of each item in large IPS table, |
| 76 | * here next_hop is not needed. |
| 77 | */ |
| 78 | generate_large_ips_table(0); |
| 79 | |
| 80 | lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); |
| 81 | TEST_LPM_ASSERT(lpm != NULL); |
| 82 | |
| 83 | /* Measure add. */ |
| 84 | begin = rte_rdtsc(); |
| 85 | |
| 86 | for (i = 0; i < NUM_ROUTE_ENTRIES; i++) { |
| 87 | if (rte_lpm6_add(lpm, large_route_table[i].ip, |
| 88 | large_route_table[i].depth, next_hop_add) == 0) |
| 89 | status++; |
| 90 | } |
| 91 | /* End Timer. */ |
| 92 | total_time = rte_rdtsc() - begin; |
| 93 | |
| 94 | printf("Unique added entries = %d\n", status); |
| 95 | printf("Average LPM Add: %g cycles\n", |
| 96 | (double)total_time / NUM_ROUTE_ENTRIES); |
| 97 | |
| 98 | /* Measure single Lookup */ |
| 99 | total_time = 0; |
| 100 | count = 0; |
| 101 | |
| 102 | for (i = 0; i < ITERATIONS; i ++) { |
| 103 | begin = rte_rdtsc(); |
| 104 | |
| 105 | for (j = 0; j < NUM_IPS_ENTRIES; j ++) { |
| 106 | if (rte_lpm6_lookup(lpm, large_ips_table[j].ip, |
| 107 | &next_hop_return) != 0) |
| 108 | count++; |
| 109 | } |
| 110 | |
| 111 | total_time += rte_rdtsc() - begin; |
nothing calls this directly
no test coverage detected