[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-optimize
Subject: Re: Mimetype optimization
From: David Faure <faure () kde ! org>
Date: 2008-04-22 20:36:09
Message-ID: 200804222236.10663.faure () kde ! org
[Download RAW message or body]
On Tuesday 22 April 2008, Jakub Stachowski wrote:
> Hello,
>
> profiling dolphin while opening /usr/bin shows that about 35% of time is spent
> in QRegExp matching called by kmimefactory.cpp: matchFileName. This function
> already contains optimizations: for some simple (but popular) patterns like
> *.something or something* it uses direct comparision instead of QRegExp big
> gun. It looks like:
> if (pattern like *.something && filename long enough to match the pattern)
> compare directly;.
> However for short names (lots of them in /usr/bin) it often falls back to slow
> path. Attached patch changes is to:
> if (pattern like *.something) {
> if (filename not long enough to match) return false;
> else compare directly;
> }
>
> and detects patterns without wildcards (is checking for *,? and ] enough?)
>
> Results (measured by callgrind):
> Unpatched, for 179 calls to KMimeTypeFactory::findFromFileName
> - 5554 calls to QRegExp::exactMatch, which accounts for 35% of CPU time
>
> Patched, for 150 calls to KMimeTypeFactory::findFromFileName
> - QRegExp matched 13 times. findFromFileName takes 0.67% of CPU time
Wow, excellent. Great find.
If the kdecore/tests/kmimetypetest unit test still passes, please commit :)
--
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
_______________________________________________
Kde-optimize mailing list
Kde-optimize@kde.org
https://mail.kde.org/mailman/listinfo/kde-optimize
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic