You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Rick Bullotta <Ri...@lighthammer.com> on 2005/04/24 17:13:59 UTC

RE: Transform Performance (was: 1.6 Rendering/Rasterization Performance Versus 1.5)

Looks like not a 1.6 vs 1.5 issue - the benchmark comparisons one of our
developers was using (that brought to light the performance issue) were
versus a .NET rendering engine (SharpVectorGraphics) for some sample
drawings.  In general, Batik is about 40% faster, except under certain
conditions (which we're trying to identify), at which point the
performance advantage switches over substantially to
SharpVectorGraphics.

 

The particular SVG object that is showing this behavior has a lot of
sequential translate transforms on text (an artifact of the drawing tool
used to create the drawing) along with a number of rotate transforms on
line and polygon objects.  The only other things of interest in the
drawing are a few "wide-stroked" arcs and a radial gradient.

 

Any optimizations/known design considerations for getting the best
performance out of Batik (the SVG causing the performance deviation is
shown below)?

 

<?xml version="1.0"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svg width="300" height="300">

       <defs>

              <radialGradient id="black-white_1" cx="70%" cy="30%"
r="50%" fx="80%" fy="40%" spreadMethod="pad"
gradientUnits="objectBoundingBox">

                     <stop stop-color="rgb(240,240,240)" offset="0%"
stop-opacity="1"/>

                     <stop stop-color="rgb(180,180,180)" offset="100%"
stop-opacity="1"/>

              </radialGradient>

       </defs>

       <ellipse fill="url(#black-white_1)" stroke="rgb(0,0,0)"
stroke-width="1" cx="150" cy="150" rx="140" ry="140"/>

       <ellipse stroke="url(#black-white_1)" stroke-width="4" fil
l="none" cx="150" cy="150" rx="140" ry="140"/>

       <ellipse fill="rgb(0,0,0)" stroke="rgb(0,0,0)" stroke-width="1"
cx="150" cy="150" rx="12" ry="12"/>

       <ellipse fill="none" stroke="rgb(0,0,0)" stroke-width="2"
cx="150" cy="150" rx="142" ry="142"/>

       <path id="GreenArc" fill="none" stroke="rgb(0,255,0)"
stroke-width="12" d="M107.59 266.52 C59.965 249.197 25.9998 203.564
25.9998 149.998 C25.9998 81.5147 81.5164

                     25.998 150 25.998 C218.483 25.998 274 81.5147 274
149.998 C274 202.886

                     240.889 248.041 192.41 266.52"/>

       <path id="YellowArc" fill="none" stroke="rgb(255,255,0)"
stroke-width="12" d="M107.59 266.52 C59.9655 249.197 26.0002 203.564
26.0002 149.998 C26.0002 81.5149

                     81.5169 25.9982 150 25.9982 C218.483 25.9982 274
81.5149 274 149.998 C274 154.066

                     273.804 158.089 273.321 162.962"/>

       <path id="RedArc" fill="none" stroke="rgb(255,0,0)"
stroke-width="12" d="M107.59 266.52 C59.958 249.195 25.9928 203.562
25.9928 149.995 C25.9928 81.5122 81.5095

                     25.9955 149.993 25.9955 C173.725 25.9955 195.899
32.6623 215.71 44.842"/>

       <path fill="none" stroke="rgb(0,0,0)" stroke-width="4"
d="M108.958 262.763 C62.8696 245.999 30 201.838 30 150 C30 83.7258
83.7258 30 150 30

                     C216.274 30 270 83.7258 270 150 C270 201.182
237.957 244.88 191.042 262.763"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(20 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(52 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(84 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(116 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(148 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(180 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(212 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(244 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(276 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(308 150 150)"/>

       <line fill="none" stroke="rgb(0,0,0)" stroke-width="3" x1="150"
y1="270" x2="150" y2="250" transform="rotate(340 150 150)"/>

       <text id="Label0" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(43 31) translate(0 -6) translate(1 0) translate(1 0)
translate(1 0) translate(1 0) translate(1 0) translate(-1 0) translate(0
1) translate(0 1) translate(0 1)" text-anchor="middle">0</text>

       <text id="Label1" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(11 -8) translate(-7 7) translate(0 -1) translate(0
-1)">10</text>

       <text id="Label2" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(-14 -44)">20</text>

       <text id="Label3" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(-4 -86) translate(0 -1) translate(0 -1) translate(0 -1)
translate(-1 0)">30</text>

       <text id="Label4" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(21 -125) translate(1 0)">40</text>

       <text id="Label5" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(67 -140) translate(1 0) translate(1 0) translate(1 0)
translate(1 0) translate(1 0) translate(1 0) translate(1 0) translate(1
0) translate(1 0) translate(1 0) translate(1 0) translate(1 0)
translate(1 0) translate(1 0) translate(-1 0)"
text-anchor="middle">50</text>

       <text id="Label6" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(110 -126) translate(0 1) translate(1 0) translate(1 0)
translate(10 0) translate(10 0) translate(10 0) translate(-1 0)
translate(-1 0) translate(-1 0) translate(-1 0)"
text-anchor="end">60</text>

       <text id="Label7" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(138 -89) translate(0 -1) translate(1 0) translate(10 0)
translate(10 0) translate(10 0) translate(-1 0) translate(-1 0)
translate(-1 0)" text-anchor="end">70</text>

       <text id="Label8" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(148 -46) translate(1 0) translate(0 1) translate(10 0)
translate(10 0) translate(1 0) translate(1 0) translate(1 0) translate(1
0) translate(1 0)" text-anchor="end">80</text>

       <text id="Label9" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(133 -1) translate(10 0) translate(10 0) translate(1 0)
translate(1 0) translate(1 0) translate(1 0) translate(1 0) translate(-1
0) translate(-1 0) translate(0 -1) translate(0 -1)"
text-anchor="end">90</text>

       <text id="Label10" fill="rgb(0,64,0)" font-size="16"
font-family="Arial Black" x="78px" y="197px" transform="translate(-7 13)
translate(92 25) translate(-1 0) translate(0 1) translate(0 -1)
translate(1 0) translate(1 0) translate(1 0) translate(1 0) translate(1
0) translate(1 0) translate(1 0) translate(1 0) translate(1 0)
translate(1 0) translate(1 0) translate(1 0) translate(1 0) translate(1
0) translate(1 0) translate(1 0) translate(0 1) translate(0 1)
translate(0 1)" text-anchor="middle">100</text>

       <rect fill="rgb(0,0,0)" stroke="rgb(192,192,192)"
stroke-width="1" x="130" y="176" width="40" height="40"/>

       <polygon id="Indicator" points="138.544,189.702 150.044,182.544
161.544,189.702 154.554,189.702 154.554,204.544 145.309,204.544

                     145.309,189.702" fill="rgb(0,255,0)"
stroke="rgb(0,0,0)" stroke-width="1" transform="rotate(360 150 196)"/>

       <text id="TopLabel" fill="rgb(0,64,0)" font-size="10"
text-anchor="middle" font-family="Arial Black" x="150"
y="110">Cost</text>

       <text id="BottomLabel" fill="rgb(0,64,0)" font-size="10"
text-anchor="middle" font-family="Arial Black" x="150"
y="126">Performance</text>

       <line id="Needle" fill="none" stroke="rgb(255,20,20)"
stroke-width="5" x1="150" y1="150" x2="150" y2="260"
stroke-linecap="round" transform="rotate(330 150 150)"/>

</svg>

 


Re: Transform Performance (was: 1.6 Rendering/Rasterization Performance Versus 1.5)

Posted by Thomas DeWeese <Th...@Kodak.com>.
Rick Bullotta wrote:

> Looks like not a 1.6 vs 1.5 issue - the benchmark comparisons one of our 
> developers was using (that brought to light the performance issue) were 
> versus a .NET rendering engine (SharpVectorGraphics) for some sample 
> drawings.  In general, Batik is about 40% faster, except under certain 
> conditions (which we’re trying to identify), at which point the 
> performance advantage switches over substantially to SharpVectorGraphics.
> 
> The particular SVG object that is showing this behavior has a lot of 
> sequential translate transforms on text (an artifact of the drawing tool 
> used to create the drawing) along with a number of rotate transforms on 
> line and polygon objects.  The only other things of interest in the 
> drawing are a few "wide-stroked" arcs and a radial gradient.

    A quick analysis of the document shows the following times:
	~100ms for the radialGradient (this is a little odd since you
	       fill a circle with the gradient then stroke it which
	       seems a bit odd).
         ~40ms  for the text (text is known to be on the slow side,
	       lots of small pieces of text are the worst.
	~80ms  The rest...

> Any optimizations/known design considerations for getting the best 
> performance out of Batik (the SVG causing the performance deviation is 
> shown below)?

    I think the problem is likely the radial gradient.  Right now this
code uses a fair amount of float (including sqrt's).   I've tried
several times to replace this with various optimizations and they
have all more or less failed.  It's tricky to do right...

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org