* This basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */
| 143 | * threads and finally how long per packet the processing took. |
| 144 | */ |
| 145 | static inline int |
| 146 | perf_test(struct rte_distributor *d, struct rte_mempool *p) |
| 147 | { |
| 148 | unsigned int i; |
| 149 | uint64_t start, end; |
| 150 | struct rte_mbuf *bufs[BURST]; |
| 151 | |
| 152 | clear_packet_count(); |
| 153 | if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) { |
| 154 | printf("Error getting mbufs from pool\n"); |
| 155 | return -1; |
| 156 | } |
| 157 | /* ensure we have different hash value for each pkt */ |
| 158 | for (i = 0; i < BURST; i++) |
| 159 | bufs[i]->hash.usr = i; |
| 160 | |
| 161 | start = rte_rdtsc(); |
| 162 | for (i = 0; i < (1<<ITER_POWER); i++) |
| 163 | rte_distributor_process(d, bufs, BURST); |
| 164 | end = rte_rdtsc(); |
| 165 | |
| 166 | do { |
| 167 | usleep(100); |
| 168 | rte_distributor_process(d, NULL, 0); |
| 169 | } while (total_packet_count() < (BURST << ITER_POWER)); |
| 170 | |
| 171 | rte_distributor_clear_returns(d); |
| 172 | |
| 173 | printf("Time per burst: %"PRIu64"\n", (end - start) >> ITER_POWER); |
| 174 | printf("Time per packet: %"PRIu64"\n\n", |
| 175 | ((end - start) >> ITER_POWER)/BURST); |
| 176 | rte_mempool_put_bulk(p, (void *)bufs, BURST); |
| 177 | |
| 178 | for (i = 0; i < rte_lcore_count() - 1; i++) |
| 179 | printf("Worker %u handled %u packets\n", i, |
| 180 | worker_stats[i].handled_packets); |
| 181 | printf("Total packets: %u (%x)\n", total_packet_count(), |
| 182 | total_packet_count()); |
| 183 | printf("=== Perf test done ===\n\n"); |
| 184 | |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | /* Useful function which ensures that all worker functions terminate */ |
| 189 | static void |
no test coverage detected