shared: use NMStrBuf in _nm_utils_enum_to_str_full()
Just for showcase and to hit the code from the unit-tests
that we have.
Also, just to show, the following runs about 25 % faster than before,
which isn't bad for such a simple replacement.
{
GType gtype = nm_test_general_color_flags_get_type ();
const int N_RUN = 1000000;
int i_run;
guint8 c = 0;
for (i_run = 0; i_run < N_RUN; i_run++) {
gs_free char *str = NULL;
str = _nm_utils_enum_to_str_full (gtype, i_run % 10, ",", NULL);
c += str[0];
}
return c % 3;
}
$ perf stat -r 200 -B libnm-core/tests/test-general
Before:
Performance counter stats for 'libnm-core/tests/test-general' (200 runs):
204.48 msec task-clock:u # 0.997 CPUs utilized ( +- 0.53% )
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
267 page-faults:u # 0.001 M/sec ( +- 0.05% )
702,987,494 cycles:u # 3.438 GHz ( +- 0.54% )
1,698,874,415 instructions:u # 2.42 insn per cycle ( +- 0.00% )
410,394,229 branches:u # 2006.970 M/sec ( +- 0.00% )
1,770,484 branch-misses:u # 0.43% of all branches ( +- 0.40% )
0.20502 +- 0.00108 seconds time elapsed ( +- 0.53% )
After:
Performance counter stats for 'libnm-core/tests/test-general' (200 runs):
155.71 msec task-clock:u # 0.996 CPUs utilized ( +- 0.50% )
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
266 page-faults:u # 0.002 M/sec ( +- 0.05% )
539,994,118 cycles:u # 3.468 GHz ( +- 0.49% )
1,116,016,733 instructions:u # 2.07 insn per cycle ( +- 0.00% )
283,974,158 branches:u # 1823.760 M/sec ( +- 0.00% )
1,377,786 branch-misses:u # 0.49% of all branches ( +- 0.43% )
0.156255 +- 0.000786 seconds time elapsed ( +- 0.50% )