| 728 | } |
| 729 | |
| 730 | static int |
| 731 | sketch_test(uint32_t *keys, uint32_t total_pkt, int count_byte, int reset_test) |
| 732 | { |
| 733 | uint32_t i; |
| 734 | uint64_t result_count[SKETCH_TOTAL_KEY]; |
| 735 | member_set_t heavy_set[SKETCH_TOTAL_KEY]; |
| 736 | uint64_t count[TOP_K]; |
| 737 | int ret; |
| 738 | int hh_cnt; |
| 739 | |
| 740 | setsum_sketch = rte_member_create(¶ms); |
| 741 | if (setsum_sketch == NULL) { |
| 742 | printf("Creation of setsums fail\n"); |
| 743 | return -1; |
| 744 | } |
| 745 | |
| 746 | for (i = 0; i < total_pkt; i++) { |
| 747 | if (count_byte) |
| 748 | ret = rte_member_add_byte_count(setsum_sketch, &keys[i], HH_PKT_SIZE); |
| 749 | else |
| 750 | ret = rte_member_add(setsum_sketch, &keys[i], 1); |
| 751 | |
| 752 | if (ret < 0) { |
| 753 | printf("rte_member_add Failed! Error [%d]\n", ret); |
| 754 | rte_member_free(setsum_sketch); |
| 755 | |
| 756 | return -1; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | for (i = 0; i < SKETCH_TOTAL_KEY; i++) { |
| 761 | uint32_t tmp_key = i; |
| 762 | |
| 763 | rte_member_query_count(setsum_sketch, (void *)&tmp_key, &result_count[i]); |
| 764 | rte_member_lookup(setsum_sketch, (void *)&tmp_key, &heavy_set[i]); |
| 765 | } |
| 766 | |
| 767 | print_out_sketch_results(result_count, heavy_set, PRINT_OUT_COUNT, count_byte); |
| 768 | |
| 769 | hh_cnt = rte_member_report_heavyhitter(setsum_sketch, heavy_hitters, count); |
| 770 | if (hh_cnt < 0) { |
| 771 | printf("sketch report heavy hitter error!"); |
| 772 | rte_member_free(setsum_sketch); |
| 773 | |
| 774 | return -1; |
| 775 | } |
| 776 | |
| 777 | printf("Report heavy hitters:"); |
| 778 | for (i = 0; i < (unsigned int)hh_cnt; i++) { |
| 779 | printf("%u: %"PRIu64"\t", |
| 780 | *((uint32_t *)heavy_hitters[i]), count[i]); |
| 781 | } |
| 782 | printf("\n"); |
| 783 | |
| 784 | if (reset_test) { |
| 785 | printf("\nEntering Sketch Reset Test Process!\n"); |
| 786 | rte_member_reset(setsum_sketch); |
| 787 |
no test coverage detected