[patch] on the performance of KisCircleMaskGenerator::valueAt
Geoffry Song
goffrie at gmail.com
Fri Dec 24 17:17:41 CET 2010
On Fri, Dec 24, 2010 at 8:40 AM, Dmitry Kazakov <dimula73 at gmail.com> wrote:
>
>
> On Fri, Dec 24, 2010 at 7:00 AM, Geoffry Song <goffrie at gmail.com> wrote:
>>
>> I noticed that KisCircleMaskGenerator::valueAt(), which can easily be
>> called millions of times in a single stroke, has some rather
>> inefficient code (in particular, an unnecessary sqrt()), so I took the
>> liberty of optimizing the code a bit. This patch should somewhat
>> improve the performance of large brushes, especially the sketch brush
>> with a large diameter. No, it is not a large difference.
>>
>> On my machine, the old code took about 26 nanoseconds per call, and
>> the new code takes 15 nanoseconds per call.
>>
>> (Raw data: old code, time per call: 2.6188e-08, 2.6148e-08, 2.612e-08,
>> 2.6688e-08, 2.668e-08, 2.6868e-08. New code: 1.4952e-08, 1.5532e-08,
>> 1.4972e-08, 1.4964e-08, 1.4892e-08, 1.4868e-08, 1.4876e-08,
>> 1.5144e-08, 1.4872e-08, 1.4872e-08, 1.4876e-08. Each sample is an
>> average over 2.5 billion calls)
>
> Hi!
> Cool patch! We have special benchmarks for strokes in Krita. They are placed
> in ./krita/benchmarks/ folder. The one that tests strokes is called
> KisStrokeBenchmark (you need to have BUILD_TESTS set to on in cmake).
>
> Your numbers from callgrind (i guess) look cool! It would be interesting to
> see the results of that benchmark ;)
The numbers are actually from a very crude benchmark I put into the
constructor.
I ran KisStrokeBenchmark 20 times each for the old and new code. Only
the first two tests (pixelbrush300px and bixpelbrush300pxRL) call
KisCircleMaskGenerator::valueAt a significant number of times, so
unsurprisingly they are the only benchmarks that show a significant
change: 489.9 msec (stdev 14.62) to 456.8 msec (stdev 14.20) for
pixelbrush300px, and 2788 msec (stdev 73.25) to 2619 msec (stdev
88.89) for pixelbrush300pxRL. It's not a big difference, but it's
there.
--
Segmentation fault
More information about the kimageshop
mailing list