Discussion:
Perf - No. of rects vs area of rects
Abhas Bhattacharya
2014-06-15 01:13:15 UTC
Permalink
Does the performance of pygame.update depend solely on no. of rects or
total area of all rects passed to it?
I was thinking of a small speedup by splitting two intersecting rects into
three non-intersecting rects, which will reduce the toal area, but increase
the no. of rects.
Its probably a very small gain, and might result in a actual loss if the
no. of rects explode. But if I know for sure that performance depende
solely on one factor or the other, small gains like h=this might be
possible.
Jason Marshall
2014-06-15 18:56:44 UTC
Permalink
Number of rects is not very important. 

The total area is much more important. Also, aligning surface widths to multiples of 16 and blitting to locations on the x axis that are multiples of 16 can help the performance of the blitting. (I just learned that from this mailing list.) Setting the source surface's RLEACCEL flag helps if there is a lot of solid coloration in your source surface.

This script reduces the update area as much as possible:
  https://bitbucket.org/jmm0/optimize_dirty_rects/downloads

Jason



From:Abhas Bhattacharya <abhasbhattacharya2-***@public.gmane.orgm>
To: pygame-mirror-on-google-groups-/***@public.gmane.org
Sent: Saturday, June 14, 2014 8:13 PM
Subject: [pygame] Perf - No. of rects vs area of rects



Does the performance of pygame.update depend solely on no. of rects or total area of all rects passed to it?
I was thinking of a small speedup by splitting two intersecting rects into three non-intersecting rects, which will reduce the toal area, but increase the no. of rects.
Its probably a very small gain, and might result in a actual loss if the no. of rects explode. But if I know for sure that performance depende solely on one factor or the other, small gains like h=this might be possible.
Abhas Bhattacharya
2014-06-18 02:49:14 UTC
Permalink
What does the RLEACCEL flag do?
Peter Shinners
2014-06-18 05:02:31 UTC
Permalink
It stands for "Run Length Encoding". SDL had some optimized blitters
that would work with runs of pixels with the same value. I'm not sure if
any of that is still supported. It may provide a small performance boost
for specialized cases. I'm pretty sure an RLEACCEL surface cannot be
modified (locked)?
Post by Abhas Bhattacharya
What does the RLEACCEL flag do?
Loading...