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

Function sketch_test

dpdk/app/test/test_member.c:730–870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728}
729
730static int
731sketch_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(&params);
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

Callers 1

test_member_sketchFunction · 0.85

Calls 11

rte_member_createFunction · 0.85
rte_member_addFunction · 0.85
rte_member_freeFunction · 0.85
rte_member_query_countFunction · 0.85
rte_member_lookupFunction · 0.85
print_out_sketch_resultsFunction · 0.85
rte_member_resetFunction · 0.85
rte_member_deleteFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected