perfmon: sort 'show perfmon bundle' output 08/33508/3
authorZachary Leaf <zachary.leaf@arm.com>
Tue, 17 Aug 2021 09:12:01 +0000 (04:12 -0500)
committerDamjan Marion <dmarion@me.com>
Wed, 8 Sep 2021 14:34:44 +0000 (14:34 +0000)
This patch sorts 'show perfmon bundle' output in alphabetical order.

Type: improvement
Signed-off-by: Zachary Leaf <zachary.leaf@arm.com>
Change-Id: I26b379b5d6766b9f87f9a3a5013ea92b207fb5d4

src/plugins/perfmon/cli.c

index 1535570..ce191ea 100644 (file)
@@ -91,6 +91,15 @@ format_perfmon_bundle (u8 *s, va_list *args)
   return s;
 }
 
+static int
+bundle_name_sort_cmp (void *a1, void *a2)
+{
+  perfmon_bundle_t **n1 = a1;
+  perfmon_bundle_t **n2 = a2;
+
+  return clib_strcmp ((char *) (*n1)->name, (char *) (*n2)->name);
+}
+
 static clib_error_t *
 show_perfmon_bundle_command_fn (vlib_main_t *vm, unformat_input_t *input,
                                vlib_cli_command_t *cmd)
@@ -127,6 +136,8 @@ show_perfmon_bundle_command_fn (vlib_main_t *vm, unformat_input_t *input,
   if (verbose == 0)
     vlib_cli_output (vm, "%U\n", format_perfmon_bundle, 0, 0);
 
+  vec_sort_with_function (vb, bundle_name_sort_cmp);
+
   for (int i = 0; i < vec_len (vb); i++)
     /* bundle type will be unknown if no cpu_supports matched */
     if (vb[i]->type != PERFMON_BUNDLE_TYPE_UNKNOWN)