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

Function test_member_sketch

dpdk/app/test/test_member.c:872–952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872static int
873test_member_sketch(void)
874{
875 unsigned int i, j, index;
876 uint32_t total_pkt = 0;
877 uint32_t *keys;
878 int count_byte = 0;
879
880 for (i = 0; i < SKETCH_TOTAL_KEY; i++)
881 total_pkt += ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1));
882
883 printf("\nTotal key count [%u] in Sketch Autotest\n", total_pkt);
884
885 keys = rte_zmalloc(NULL, sizeof(uint32_t) * total_pkt, 0);
886
887 if (keys == NULL) {
888 printf("RTE_ZMALLOC failed\n");
889 return -1;
890 }
891
892 index = 0;
893 for (i = 0; i < SKETCH_TOTAL_KEY; i++) {
894 for (j = 0; j < ceil((double)SKETCH_LARGEST_KEY_SIZE / (i + 1)); j++)
895 keys[index++] = i;
896 }
897
898 /* shuffle the keys */
899 for (i = index - 1; i > 0; i--) {
900 uint32_t swap_idx = rte_rand() % i;
901 uint32_t tmp_key = keys[i];
902
903 keys[i] = keys[swap_idx];
904 keys[swap_idx] = tmp_key;
905 }
906
907 params.key_len = 4;
908 params.name = "test_member_sketch";
909 params.type = RTE_MEMBER_TYPE_SKETCH;
910 params.error_rate = SKETCH_ERROR_RATE;
911 params.sample_rate = SKETCH_SAMPLE_RATE;
912 params.extra_flag = 0;
913 params.top_k = TOP_K;
914 params.prim_hash_seed = rte_rdtsc();
915 int reset_test = 0;
916
917 printf("Default sketching params: Error Rate: [%f]\tSample Rate: [%f]\tTopK: [%d]\n",
918 SKETCH_ERROR_RATE, SKETCH_SAMPLE_RATE, TOP_K);
919
920 printf("\n[Sketch with Fixed Sampling Rate Mode]\n");
921 if (sketch_test(keys, total_pkt, count_byte, reset_test) < 0) {
922 rte_free(keys);
923 return -1;
924 }
925
926 params.extra_flag |= RTE_MEMBER_SKETCH_ALWAYS_BOUNDED;
927 printf("\n[Sketch with Always Bounded Mode]\n");
928 if (sketch_test(keys, total_pkt, count_byte, reset_test) < 0) {
929 rte_free(keys);

Callers 1

test_memberFunction · 0.85

Calls 6

rte_zmallocFunction · 0.85
rte_randFunction · 0.85
sketch_testFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50
rte_rdtscFunction · 0.50

Tested by

no test coverage detected