Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Sun, 30 Mar 2008 15:41:55 -0700 (PDT)
On Mar 30, 10:18 pm, max vorticity <max.vortic...@xxxxxxxxxxx> wrote:
I had an error in my analysis so the slowness is not really
attributable to the itemconfigure command. So forget my original post
except that when using a lot of tags, it is much slower to address the
items by individual tags for each polygon than by the original canvas
id
Yes, this is due to the fact that lookup by id uses a hashtable, while
lookup by tag implies a linear search.
But at the same time, the internal iterator over the items of a tag
has a small linear constant (because it's in C). More precisely, if a
canvas has N items, of which K hold the tag T, then
.c itemconfigure T -fill red
will take a*N+b*K, where a and b are rather small (C iteration).
While if you store the same K ids in a list l, then
foreach i $l {.c itemconfigure $i -fill red}
will take c*K, where c is much larger than a and b (Tcl iteration)
So, there is a point of equilibrium where tags become faster than
individual ids to handle groups of items.
Reaching this regime implies to have tags with many items each (large
K), that's why I asked about your ability to quantize the colors. But
I admit that other overheads must be taken into account, since tag
handling implies to use addtag and dtag frequently...
id's appears to be noticably faster. My application has over 80000
canvas items and I amazed at how well the canvas does.
Case closed, then ?
-Alex
.
- Follow-Ups:
- References:
- Speedup canvas itemconfigure -fill for many polygons.
- From: max vorticity
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: max vorticity
- Speedup canvas itemconfigure -fill for many polygons.
- Prev by Date: Re: where is expand {@}?
- Next by Date: Re: Tclhttpd: why not return the HTTP status from Direct_Url?
- Previous by thread: Re: Speedup canvas itemconfigure -fill for many polygons.
- Next by thread: Re: Speedup canvas itemconfigure -fill for many polygons.
- Index(es):
Relevant Pages
|