[wxPython-users] number of objects drawn to dc

Robin Dunn robin at alldunn.com
Tue Oct 2 12:39:20 PDT 2007


Chris Mellon wrote:
> On 10/1/07, Chris Mellon <arkanes at gmail.com> wrote:
>> I haven't profiled this, so I'm committing a cardinal sin by
>> speculating on performance-related results by just looking at the
>> source, but here's my guess.
>>
>> wxPsuedoDC (wxPDC hereafter) has a list of PDC operations. It's in Z
>> order, and a PDC operation is a list of actual drawing operations +
>> some metadata.
>>
>> When you call SetID(), that just sets the ID that the next drawing
>> operation will use.
>>
>> When you do a drawing operation, it calls AddToList, which scans the
>> current list of operations for the current id, fails to find it, and
>> then creates a new one. There's an optimization in the search for
>> using the last ID, so repeated draws with the same ID are fast, but a
>> draw with a new id is slow - there's a linear search for each id, so
>> the time complexity for drawing n individual IDs is over O(n**2).
>>
>> Adding an index for id->node lookups is probably the best solution.
>>
> 
> 
> Attached is a patch to implement this.

Thanks!

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list