Jeff,
I tried out your example, I can confirm that it runs in about 3
seconds (3.5 seconds on my PC in IE 8 with IE7 compatibility mode
turned on). 3.5 seconds for 100 circles is still a lot of time, but a
lot better than 10 seconds.
I cannot immediately reconcile the discrepancy between the profiler
output from our examples. Each call to setBox takes considerably less
time in your example then in our example. When I run your example,
setBox calls average 15.9 ms per call. In our example, setBox consumes
an average of 48 ms per call (same browser, same version of
raphael.js). There must be some other difference between our circle
elements or how we construct them -- I just don't see it at this point
(the VML DOM structure appears identical).
Note that our example also includes 119 lines (paths). I previously
reported an average of 20 ms per setBox call, but that number included
setBox calls from lines and circles. Line setBox calls take very
little time (<1 ms per call). When I don't include line setBox calls
the average goes up to 48 ms per call (as reported above). 200*48 =
9600 ms, which is a majority of the 11 second run time.
Your example calls theCircle() 100 times and then attr() 100 times.
The circle calls take a total of 1997 ms and attr 1482 ms for a total
of about 3.5 seconds:
Circle (100, 1997.33 ms)
-> theCircle (100,1997.33 ms)
-> setBox (100, 1732.06 ms)
-> setFillAndStroke (100, 265.27 ms)
attr (100, 1482.39 ms)
-> setBox (100, 1451.18 ms)
-> setFillAndStroke (100, 31.21 ms)
Unlike your example, our example intersperses circle and attribute
calls (we draw by row so for example, there will be 4 circle then 4
attribute, and then 16 circle and 16 attribute calls, etc). Maybe this
changes how IE builds its DOM and therefore has a detrimental affect
on IE performance (though the profile output indicates that setBox
calls consistently take ~50 ms, runtime does not seem to increase as
circles are added). I also see that you are using jQuery, it's
possible that it has some positive affect on performance.
Regardless of the discrepancy (3.5 vs 10), it still would be nice to
know why setBox takes so long on IE compared with FF, Safari, etc. As
I said in my original posting, the code in setBox that consume a
majority of the time are those that set styles attributes on VML group
elements containing a circle or rect. Setting style attributes on the
actual oval element takes no time at all:
<rvml:group style="POSITION: absolute; WIDTH: 900px; HEIGHT: 450px;
TOP: 150px; LEFT: -383px" coordsize = "900,450">
<rvml:oval style="POSITION: absolute; WIDTH: 4px; HEIGHT: 4px; TOP:
223px; LEFT: 448px" coordsize = "21600,21600" filled = "t" fillcolor =
"#aaa" stroked = "t" strokecolor = "black"><rvml:fill type = "solid"></
rvml:fill>
<rvml:stroke opacity = "1" miterlimit = "8">
</rvml:stroke>
</rvml:oval>
</rvml:group>
Chris