formatNumber performance

David Faure faure at
Mon May 15 14:28:13 BST 2006

On Monday 15 May 2006 15:11, Thiago Macieira wrote:
> John Tapsell wrote:
> >Hi,
> >  I use formatNumber from kdelibs (in trunk) a lot in ksysguard but
> >the performance is awful.  It appears that it calls the config classes
> >every time it's used.  This one function accounts for 10% of my CPU
> >Usage in ksysguard.
> >
> >Can someone knowledgable look into this?  Can formatNumber be improved
> > please?
> It could cache whatever configuration it needs, though it would also mean 
> running applications would not see a config change when the user changed 
> his settings.
> I guess the proper fix lies in KConfig.

Are we talking about KLocale::formatNumber? Where does it read configuration from KConfig? I don't see that.

John: if you profiled it, you can tell better than anyone else why formatNumber is slow.
Which part of it is slow? 
The regexp? (regexps are usually slow, but is its code path activated often?)
The calls to section()? This splitting could be done faster indeed, with a single indexOf.

David Faure, faure at, sponsored by Trolltech to work on KDE,
Konqueror (, and KOffice (

More information about the kde-core-devel mailing list