sink.text.pretty: do not printf field name strings
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 Jun 2019 19:33:51 +0000 (15:33 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 21 Jul 2019 15:39:24 +0000 (11:39 -0400)
Use g_string_append rather than the printf counterpart to output field
name strings. This significantly improves pretty printing speed
(34s -> 29s on reference trace).

This is a performance improvement mainly because only strings are passed
to printf in this case.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4df52308c61346a81e0b79b079d53be52084707f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1504
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/text/pretty/print.c

index 5803d4fcfb1d86405b30aa118ac4edbc10ca29d0..c882e76b58ca6c6c7045026cae31a8d7dacb3586 100644 (file)
@@ -60,22 +60,26 @@ static
 void print_name_equal(struct pretty_component *pretty, const char *name)
 {
        if (pretty->use_colors) {
-               bt_common_g_string_append_printf(pretty->string, "%s%s%s = ", COLOR_NAME,
-                       name, COLOR_RST);
+               g_string_append(pretty->string, COLOR_NAME);
+               g_string_append(pretty->string, name);
+               g_string_append(pretty->string, COLOR_RST);
        } else {
-               bt_common_g_string_append_printf(pretty->string, "%s = ", name);
+               g_string_append(pretty->string, name);
        }
+       g_string_append(pretty->string, " = ");
 }
 
 static
 void print_field_name_equal(struct pretty_component *pretty, const char *name)
 {
        if (pretty->use_colors) {
-               bt_common_g_string_append_printf(pretty->string, "%s%s%s = ",
-                       COLOR_FIELD_NAME, name, COLOR_RST);
+               g_string_append(pretty->string, COLOR_FIELD_NAME);
+               g_string_append(pretty->string, name);
+               g_string_append(pretty->string, COLOR_RST);
        } else {
-               bt_common_g_string_append_printf(pretty->string, "%s = ", name);
-       }
+               g_string_append(pretty->string, name);
+}
+       g_string_append(pretty->string, " = ");
 }
 
 static
This page took 0.025802 seconds and 4 git commands to generate.