diff options
author | 2015-12-15 13:22:37 +0000 | |
---|---|---|
committer | 2015-12-15 13:22:37 +0000 | |
commit | 317be0349275f1f461028853d936670729591796 (patch) | |
tree | 2423d844a2f9ed9176f54ce5d07a368e248e9e6f /vppinfra/vppinfra/test_timing_wheel.c | |
parent | ec65a1afd3f118849a7629d99ab2a1dcd2dda341 (diff) | |
parent | d2dc3df90d20419dfaee03f3096ed18d20fa391a (diff) |
Merge "replacing all vec_sort() invocations to vec_sort_with_function()"
Diffstat (limited to 'vppinfra/vppinfra/test_timing_wheel.c')
-rw-r--r-- | vppinfra/vppinfra/test_timing_wheel.c | 22 |
1 files changed, 16 insertions, 6 deletions
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) |