Re: Some performance notes



Tim Janik <timj gtk org> writes:

> > Superficially glancing over the code in gobject.c I can see
> > two possible reasons for the g_object_new() slowness:
> > - properties are identified by strings, where g_param_spec_pool_lookup()
> >   has to parse the class_name:property_name combination (twice, once in
> >   g_object_new_valist, and again in g_object_newv)
> 
> the "class_name:property_name" syntax is strongly deprecated, people
> should just use "property_name". g_param_spec_pool_lookup() first
> attempts to lookup the property as "property_name" and only if that fails
> falls back to looking for ':'. so don't use "class_name:" prefixing and
> you don't pay extra string-contents-shuffling performance penalty for
> deprecated API ;)

The strchr() in:

  delim = pool->type_prefixing ? strchr (param_name, ':') : NULL;

in g_param_spec_pool_lookup() was showing up at the few-percent level
in my profiles. Maybe it's just an artifact of poor resolution
that it shows up so high ...

(This string shuffling bit _is_ hit no matter if you use the feature
or not.)

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]