X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vppinfra%2Fvppinfra%2Ftest_timing_wheel.c;h=8148302790570621ca7b52b50db29dfd1005f5f6;hb=e389de77de7bc08761ad1f9e1c27ba54123e4faa;hp=fa3113205c556b9abf41297fb94f085d773c2b98;hpb=cb9cadad578297ffd78fa8a33670bdf1ab669e7e;p=vpp.git diff --git a/vppinfra/vppinfra/test_timing_wheel.c b/vppinfra/vppinfra/test_timing_wheel.c index fa3113205c5..81483027905 100644 --- a/vppinfra/vppinfra/test_timing_wheel.c +++ b/vppinfra/vppinfra/test_timing_wheel.c @@ -54,6 +54,12 @@ typedef struct { f64 time_next_status_update; } test_timing_wheel_main_t; +typedef struct { + f64 dt; + f64 fraction; + u64 count; +} test_timing_wheel_tmp_t; + static void set_event (test_timing_wheel_main_t * tm, uword i) { timing_wheel_t * w = &tm->timing_wheel; @@ -70,6 +76,14 @@ static void set_event (test_timing_wheel_main_t * tm, uword i) tm->events[i] = cpu_time; } +static int test_timing_wheel_tmp_cmp (void * a1, void * a2) +{ + test_timing_wheel_tmp_t * f1 = a1; + test_timing_wheel_tmp_t * f2 = a2; + + return f1->dt < f2->dt ? -1 : (f1->dt > f2->dt ? +1 : 0); +} + clib_error_t * test_timing_wheel_main (unformat_input_t * input) { @@ -294,11 +308,7 @@ test_timing_wheel_main (unformat_input_t * input) min_error, max_error); { - struct tmp { - f64 dt; - f64 fraction; - u64 count; - } * fs, * f; + test_timing_wheel_tmp_t * fs, * f; f64 total_fraction; fs = 0; @@ -313,7 +323,7 @@ test_timing_wheel_main (unformat_input_t * input) f->count = error_hist[i]; } - vec_sort (fs, f1, f2, f1->dt < f2->dt ? -1 : (f1->dt > f2->dt ? +1 : 0)); + vec_sort_with_function (fs, test_timing_wheel_tmp_cmp); total_fraction = 0; vec_foreach (f, fs)